Repository navigation
Enable the memory observer with full support for releasing memory - #8998
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.
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.
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.