Skip to content Skip to sidebar Skip to footer

Android - Grow Heap (frag Case) - Byte Allocation.. Not Loading Any Bitmaps

This happens when the app loads from Splash screen to Main page. It happens only on the device not on simulator: 05-17 08:10:16.627: I/dalvikvm-heap(14021): Grow heap (frag case) t

Solution 1:

I have experienced the same issue and found a solution to it.

Are you loading your bitmaps from resource? if so try placing them in corresponding drawable folders instead of keeping them in "drawable" or "drawable-mdpi".

When you have your image resources in plain drawable folder, to the system it means drawable-mdpi. Therefore devices with high or extra high dpi (Galaxy Nexus I believe is Extra high) will expand that resource to match the dpi of the device.

If you only have 1 size for your resources, put them in drawable-nodpi and it will be used as is. However some of your layouts may be affected by this, so I kept certain images in the drawable folder (like button images etc.) and moved backgrounds and other bigger resources into drawable-nodpi.

Hope this helps ;)

Solution 2:

You are probably trying to decode a very big Bitmap which results in an OutOfMemory exception. It means that the operation you are trying to achieve is exceeding the VM Budget allowed for each application on your device, in terms of heap memory consumption (which appears to be 24 MB on your device, probably more on your emulator which is why it doesn't happen there!).

Try to sample your Bitmapby a factor of two for instance:

BitmapFactory.Optionso=newBitmapFactory.Options();
o.inSampleSize = 2;
Bitmapb= BitmapFactory.decodeFile(pathToBitmap, o);

Post a Comment for "Android - Grow Heap (frag Case) - Byte Allocation.. Not Loading Any Bitmaps"