Release bitmaps from android.view.GLES20DisplayList

天涯浪子 提交于 2019-12-02 18:55:10

This seems to be a memory leak in 4.2. Looks like this fix is intended against it: https://android.googlesource.com/platform/frameworks/base/+/034de6b1ec561797a2422314e6ef03e3cd3e08e0

I disabled hardware acceleration in the manifest for 4.2 for the activity where I encountered this problem, this helped with android.view.GLES20DisplayList memory holding.

In the manifest for activity: android:hardwareAccelerated="@bool/gpu_enabled"

In values.xml for v17:

<bool name="gpu_enabled">false</bool>   

In default values.xml, I set it to true.

hiBrianLee

I recently did an in-depth memory analysis regarding this issue. As Yulia pointed out above, disabling hardware acceleration would do the trick in general. Alternatively, you can set the ImageView’s Drawable to null, recycle the bitmap, or detach the ImageView as you pointed out.

However, depending on the API version, the bitmap memory may or may not be released from GLES20DisplayList. I discussed these different behaviors and possible solutions in-depth on my blog post – Android Bitmap Memory Analysis, but the quick solution would be to disable hardware acceleration.

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