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
Image widget can use large memory and never released #62107
Comments
Hi @Gorniv Code Sample
flutter doctor -v
flutter doctor -v
Thanks for reporting |
/cc @dnfield |
I'm not clear that this is a bug. If you have a large image and decode it at full resolution it will use a lot of memory. I recently added functionality to let you press I (uppercase i) in the terminal to highlight images that are larger than what you're painting. You can try this to identify images you may be decoding at too large a size, and either downsize them or use the cache width/Height params. Please feel free to add more details if something is missing here. |
I ran into that issue also. When I loaded and image with Image widget the memory increase then I push to the new screen with pushAndRemoveUntil. The memory still stored in External Memory not release when GC is executed. The memory will stack to 1000mb then crash on iPhone X if we load more images on a first page then Navigate to the new page leaves the app running the memory still not release in External Memory. This issue is easy to reproduce: |
@dnfield image size is 749 614 bytes (754 KB on disk) and use more 100 MB when I use ONE Image.asset with width == device-width of iPhone 11. |
What matters is it's decode size (roughly width x height x 4.3), not it's compressed size on disk |
I and all the developers with whom I spoke on this issue did not expect this behaviour from this widget. Its documentation and options are not intuitive. |
I'll reopen this to track updating docs |
Answered at: #60160 I have come with a similar error while using I have noticed that if I open (and close) the images page my external memory increases and is never released. If I open and close the page several times the external memory keeps increasing considerably and is never released. I am attaching a spreadsheet with the outputs of the memory snapshot. This small table shows the largest objects of the external memory at the init of the app, after opening for the first time the page with the images and after opening and closing the page ten and fifteen times (in total). I haven't manually run the GC but it is evident that what makes the memory increase is I made an extensive study with my code and came to the conclusion that it is I hope this gives you enough insights. I will be happy to answer any further question or give more details. SliverGrid code
|
same issue Flutter (Channel dev, 1.21.0-9.0.pre, on Mac OS X 10.15.6 19G73, locale zh-Hans-CN |
I have the same issue. If the picture is a moving picture, it will keep going up when the app is on. |
same issue |
same |
#65834 Could be related |
This workaround doesn't work anymore from |
The temporary solution I used is to clear the cache if image cache memory exceeds a specific range. Still, after clearing the cache, it seems the image will take some time to reload. My app has about 500 images now and is expected to increase to 10000, Hope this issue will be solved soon.
|
@sailexx why not just set the Also, clearing live images is almost never the right thing to do, since those are in memory somewhere else anyway... |
It is not working well from flutter 3.3 unfortunately #110847, but this was the workaround i was using. |
Thank you for the response,
If I remove the
I did add And also I do see a bunch of logs
But the memory use doesn't decrease, |
I switched to use extended_image and memory issues went away https://pub.dev/packages/extended_image/example |
I confirm since I been using this package for about 10 months, the OOM issue went away for me too. |
So ,Is that mean It's the question of CacheNetWorkImage not flutter's ? |
same |
Fixes flutter#112676. Fixes flutter#97015. Fixes flutter#62107. Fixes flutter#38740. Fixes flutter#31911. Fixes flutter#29958. Fixes flutter#18108. Fixes flutter#17160. Fixes flutter#14243. Fixes flutter#3354.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Details
Image.asset use from 100 to 240 Mb for One image:
Image for test
![meows_splash](https://user-images.githubusercontent.com/963316/88263474-c5aeff00-ccd2-11ea-8208-566e4209cffe.png)I tested on ios physical device with Profile mode.
Run flutter app without Image.asset:
Run with Image on 1.17.5 :
Run with Image on 1.21.0-2.0.pre94:
I found workaround - use
cacheWidth
Run workaround:
The text was updated successfully, but these errors were encountered: