Android outofmemory error bitmap size exceeds vm budget in 2.3.3

喜欢而已 提交于 2019-12-05 00:48:38

Bitmap consumes a lot of memory space. dont create a new bitmap variable for all image you load on activity, instead you can create one bitmap variable and reuse them as much as you can.

you can use this snippet to resize bitmap

http://pastebin.com/D8vbQd2u

Can you post a code snippet of the Activity + stacktrace.

Did you already check the Avoiding memory leaks article ?

Especially the following part :

When a Drawable is attached to a view, the view is set as a callback on the drawable. In the code snippet above, this means the drawable has a reference to the TextView which itself has a reference to the activity (the Context) which in turns has references to pretty much anything (depending on your code.)

It seems the images are very heavy in nature. I recommend to start the AsyncTimer which actually returns the bitmap instance and in the doBackground() of the AsyncTask pass the image id and rescale it to desire size say 32 x 32 using createScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) method of the Bitmap class.

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