i am facing a problem of OutOfMemoryError that is bitmap size exceeds vm budget while changing the orientation of the Droid mobile (but not in any of other mobiles like Android normal and Android small).I am displaying 10 images in gridview, each one size is less than 20kb.
If i insert 6 images then it doesn't arise that error.
How can i resolve this problem, any one please solve this problem. 开发者_如何学运维Thanks
Ensure two things:
1. Make sure you are not leaking memory. More info here http://android-developers.blogspot.com/2009/01/avoiding-memory-leaks.html
2. Reduce the Bitmap memory. Check if downsampling Bitmaps in an option. More info here Strange out of memory issue while loading an image to a Bitmap object.
Check SO for "Handling large Bitmaps" and "OutOfMemoryError" I am sure that are plenty of discussions that can help you here.
Just to toss in some info here, I had this exact problem (for me I found out it was the .jpg image I was using for my background).
Well I changed the image from .jpg to .png (and even resized the image a little smaller).
I think that it was the formatting of the .jpg that was giving me the error, simply changing to .png fixed the error for me.
精彩评论