Search code examples
androidandroid-asynctaskout-of-memorybitmapfactory

android confusing crash


05-07 08:27:16.910: D/dalvikvm(31777): GC_EXTERNAL_ALLOC freed 622K, 41% free 6376K/10695K, external 21288K/22163K, paused 62ms
05-07 08:27:16.972: D/dalvikvm(31777): GC_FOR_MALLOC freed <1K, 41% free 6376K/10695K, external 21455K/22163K, paused 43ms
05-07 08:27:16.988: D/skia(31777): Loading ARM decoder...
05-07 08:27:16.996: D/szipinf(31777): Initializing inflate state
05-07 08:27:17.003: D/skia(31777): Loading ARM decoder...
05-07 08:27:17.035: D/szipinf(31777): Initializing inflate state
05-07 08:27:17.050: D/skia(31777): Loading ARM decoder...
05-07 08:27:17.113: D/dalvikvm(31777): GC_EXTERNAL_ALLOC freed 181K, 40% free 6441K/10695K, external 21790K/22163K, paused 53ms
05-07 08:27:17.183: I/dalvikvm-heap(31777): Clamp target GC heap from 32.097MB to 32.000MB
05-07 08:27:17.183: D/dalvikvm(31777): GC_FOR_MALLOC freed <1K, 40% free 6441K/10695K, external 21958K/22163K, paused 43ms
05-07 08:27:17.183: D/skia(31777): Loading ARM decoder...
05-07 08:27:17.238: D/dalvikvm(31777): GC_EXTERNAL_ALLOC freed 5K, 40% free 6477K/10695K, external 21958K/22163K, paused 53ms
05-07 08:27:17.253: E/dalvikvm-heap(31777): 171600-byte external allocation too large for this process.
05-07 08:27:17.253: E/GraphicsJNI(31777): VM won't let us allocate 171600 bytes
05-07 08:27:17.300: I/dalvikvm-heap(31777): Clamp target GC heap from 32.132MB to 32.000MB
05-07 08:27:17.300: D/dalvikvm(31777): GC_FOR_MALLOC freed 0K, 40% free 6477K/10695K, external 21958K/22163K, paused 45ms
05-07 08:27:17.300: D/skia(31777): --- decoder->decode returned false
05-07 08:27:17.300: D/skia(31777): Loading ARM decoder...
05-07 08:27:17.363: W/dalvikvm(31777): threadid=13: thread exiting with uncaught exception (group=0x40015560)
05-07 08:27:17.363: D/dalvikvm(31777): GC_EXTERNAL_ALLOC freed 34K, 40% free 6476K/10695K, external 21958K/22163K, paused 59ms
05-07 08:27:17.394: E/dalvikvm-heap(31777): 171600-byte external allocation too large for this process.
05-07 08:27:17.449: I/dalvikvm-heap(31777): Clamp target GC heap from 32.131MB to 32.000MB
05-07 08:27:17.449: D/dalvikvm(31777): GC_FOR_MALLOC freed 0K, 40% free 6476K/10695K, external 21958K/22163K, paused 45ms
05-07 08:27:17.464: D/szipinf(31777): Initializing inflate state
05-07 08:27:17.496: E/GraphicsJNI(31777): VM won't let us allocate 171600 bytes
05-07 08:27:17.496: D/skia(31777): --- decoder->decode returned false
05-07 08:27:17.496: W/dalvikvm(31777): threadid=14: thread exiting with uncaught exception (group=0x40015560)
05-07 08:27:17.496: I/Process(31777): Sending signal. PID: 31777 SIG: 9
05-07 08:27:17.496: E/AndroidRuntime(31777): FATAL EXCEPTION: AsyncTask #3
05-07 08:27:17.496: E/AndroidRuntime(31777): java.lang.RuntimeException: An error occured while executing doInBackground()
05-07 08:27:17.496: E/AndroidRuntime(31777):    at android.os.AsyncTask$3.done(AsyncTask.java:200)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.FutureTask$Sync.innerSetException(FutureTask.java:274)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.FutureTask.setException(FutureTask.java:125)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:308)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1088)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.lang.Thread.run(Thread.java:1019)
05-07 08:27:17.496: E/AndroidRuntime(31777): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
05-07 08:27:17.496: E/AndroidRuntime(31777):    at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:470)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at com.test.kindle.NetworkAsync.doInBackground(NetworkAsync.java:103)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at com.test.kindle.NetworkAsync.doInBackground(NetworkAsync.java:1)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at android.os.AsyncTask$2.call(AsyncTask.java:185)
05-07 08:27:17.496: E/AndroidRuntime(31777):    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:306)
05-07 08:27:17.496: E/AndroidRuntime(31777):    ... 4 more

Why am I getting messages of VM won't let us allocate 171600 bytes and crashing with java.lang.OutOfMemoryError: bitmap size exceeds VM budget when GC messages are putting me at ~40% free?


Solution

  • After browsing the source, it seems that the bitmaps are allocated on the external heap managed by Dalvik.

    Therefore, you should be looking at the 'external' sizes reported in your log, which are indeed cutting it close.

    Other than general advice like making sure you call recycle() on any Bitmap you're done with, I doubt we can help you much more.