I recently added three small images to my apps GUI. They are around 40kb in size. Everything is fine until the screen locks on the device. When I unlock I get this error:
开发者_如何学编程OutOfMemoryError: bitmap size exceeds VM budget
I've seen plenty of articles relating to the error but all seems to be for a different reason. I'm not doing anything fancy like downloading from the internet. Just local resources for the UI.
Any suggestions welcome
Thanks
Dann
If the images are too big, and you are creating many Bitmaps
, you'll have either to properly scale the Bitmaps
before usage in code, or the shrink your resource images, if they are included in your project.
Also you have to properly use bitmap.recycle()
when you no longer use your Bitmaps
. This means that setting an Object
which contains an Bitmap
to null
or clearing an ArrayList
of Bitmaps
won't be enough. You'll first have to iterate over the Bitmaps
and call recycle()
and clear then the list.
精彩评论