-
Notifications
You must be signed in to change notification settings - Fork 345
Enable the memory observer with full support for releasing memory #8998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This may be less effective in WASM mode, where we are seeing strange results from the |
debugMeasureUsageInBytes != null | ||
? await debugMeasureUsageInBytes() | ||
: await measureMemoryUsageInBytes(); | ||
_lastMemoryUsageInBytes = memoryUsageInBytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just return this as a part of the response (could be a record), as opposed to using a long lived field to keep track of it. And then pass the starting memory usage into reduceMemory
as a parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To pass it into reduceMemory
as a parameter, we'd have to make an additional request to measureMemoryUsageInBytes
to get the latest value. It is possible that the warning has been showing for a while before the user presses "Reduce memory", so we may not have the most up to date information at the time that we show the prompt. Updating a long lived field here ensures that we always have the latest value available. Calling measureMemoryUsageInBytes
is not fast, so calling it again in an onPressed handler wouldn't be a great experience for performance.
Add the ability to release memory (see #8997) from the memory pressure prompt (see #8989).
(Ignore the threshold numbers in these gifs. The actual threshold is set to 3.0 GB.)
Successful release of memory upon clicking "Reduce memory":

Unsuccessful release of memory upon clicking "Reduce memory":

Requires #8997 to land first. Fixes #7002.