How to make sure Android bitmaps are cleared out of Heap

只愿长相守 提交于 2019-12-06 15:48:00

You could use the bitmap.recycle() method for all bitmaps loaded in memory, as long as you make sure you load them later again when you use them.

According to documentation, the recycle() method should not be used as it is considered bad practice to attempt to manage memory manually in Java. However, if you use this in conjunction with the System.gc() call I see in your onPause(), you could theoretically speed up the GC process for your problematic phones by explicitly stating unneeded bitmaps.

I don't see any Bitmap code in your snippet, maybe a bit more information could help clarify your problem.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!