Android - Grow Heap (Frag Case) - Byte Allocation.. Not Loading any bitmaps
android, memory-leaks, memory-management
Solution
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 `Bitmap`by a factor of two for instance:
BitmapFactory.Options o = new BitmapFactory.Options();
o.inSampleSize = 2;
Bitmap b = BitmapFactory.decodeFile(pathToBitmap, o);
Problem
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) to 20.580MB for 2424256-byte allocation 05-17 08:10:16.666: D/dalvikvm(14021): GC_FOR_ALLOC freed 1K, 3% free 21000K/21511K, paused 21ms 05-17 08:10:16.697: D/dalvikvm(14021): GC_CONCURRENT freed 116K, 3% free 20885K/21511K, paused 2ms+2ms 05-17 08:10:16.720: D/dalvikvm(14021): GC_FOR_ALLOC freed 44K, 4% free 20841K/21511K, paused 10ms 05-17 08:10:16.728: I/dalvikvm-heap(14021): Grow heap (frag case) to 24.533MB for 4310896-byte allocation ``` I used Ecplise MAT - the byte allocation resolved - Android.Graphics.Bitmap $preloaded images... The device I am using is Google Nexus Prime, Android 4.0 Has anyone encountered the same? Can someone throw some expertise....