Search code examples
androidgridviewout-of-memorygalleryview

Calling GridView from GalleryView causes OutOfMemoryError: bitmap size exceeds VM budget


I keep getting the above error, going from my first activity that has a galleryview of over 100 images, to a GridView activity that displays the images in a vertical Grid. Also, it does make it to the GridView activity once in a while (especially when the images are low res). From the GridView activity, once the user clicks on a particular image in the Grid, I am calling another activity that displays the selected image full-screen (or wraps to content) and the activity is bound by a ViewFlipper to flip through the images back and forth. I get the same exception here as well most times.

I am using System.gc() wherever necessary but doesn't look like that's enough. Any help?

Thanks,

Ab


Solution

  • Have you tried displaying smaller bitmaps? You can down sacle images right when you're reading in using BitmapFactory.Option when calling decodeFile.