OutOfMemoryError BitmapFactory.nativeDecodeByteArray inside Threads

by plusminus » Mon, 15 Dec 2008 01:49:32 GMT


Sponsored Links
 he following situation happens only in a few cases, but it does more
than once.
---------------------------------

I'm receiving several OutOfMemoryError in
BitmapFactory.nativeDecodeByteArray.

DDMS-Heap-View never broke the 16MB barrier. I can't even get it above
6MB, while going wild and smashing keys like a monkey:
-----------------------------------
1 5,820 MB 2,751 MB 3,069 MB 47,26% 54.433
-----------------------------------


The situation is that I have a ThreadPoolExector:
-----------------------------------
protected ExecutorService mThreadPool = Executors.newCachedThreadPool
();
-----------------------------------
... ,which load several 256x256 pngs to the RAM. (Average png-size: <
20kb)


StackTrace-Desciption:
That OutOfMemoryError happens several times in the Threads, until the
VM decides its enough and stops the whole process.

StackTrace:
#################################
W/AudioFlinger( 24): write blocked for 49 msecs
W/AudioFlinger( 24): write blocked for 48 msecs
W/AudioFlinger( 24): write blocked for 49 msecs
D/dalvikvm( 410): GC freed 31478 objects / 1613104 bytes in 196ms
D/dalvikvm( 410): GC freed 6404 objects / 991024 bytes in 151ms
D/dalvikvm( 410): GC freed 5224 objects / 1229888 bytes in 137ms
E/SOCKETLOG( 410): add_recv_stats recv 0
E/SOCKETLOG( 410): add_recv_stats recv 0
E/SOCKETLOG( 410): add_recv_stats recv 0
E/SOCKETLOG( 410): add_recv_stats recv 0
E/dalvikvm-heap( 410): 65536-byte external allocation too large for
this process.
E/dalvikvm-heap( 410): 65536-byte external allocation too large for
this process.
E/ ( 410): VM won't let us allocate 65536 bytes
W/dalvikvm( 410): threadid=59: thread exiting with uncaught exception
(group=0x40010e28)
E/AndroidRuntime( 410): Uncaught handler: thread pool-8-thread-6
exiting due to uncaught exception
E/ ( 410): VM won't let us allocate 65536 bytes
E/dalvikvm-heap( 410): 65536-byte external allocation too large for
this process.
W/dalvikvm( 410): threadid=65: thread exiting with uncaught exception
(group=0x40010e28)
E/dalvikvm-heap( 410): 65536-byte external allocation too large for
this process.
E/ ( 410): VM won't let us allocate 65536 bytes
W/dalvikvm( 410): threadid=43: thread exiting with uncaught exception
(group=0x40010e28)
E/AndroidRuntime( 410): Uncaught handler: thread pool-8-thread-3
exiting due to uncaught exception
E/AndroidRuntime( 410): java.lang.OutOfMemoryError: bitmap size
exceeds VM budget
E/AndroidRuntime( 410): at
android.graphics.BitmapFactory.nativeDecodeByteArray(Native Method)
E/AndroidRuntime( 410): at
android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:234)
E/AndroidRuntime( 410): at
android.graphics.BitmapFactory.decodeByteArray(BitmapFactory.java:247)
E/AndroidRuntime( 410): at
org.andnav2.osm.views.tiles.OSMMapTileFilesystemCache$1.run
(OSMMapTileFilesystemCache.java:234)
E/AndroidRuntime( 410): at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask
(ThreadPoolExecutor.java:648)
E/AndroidRuntime( 410): at
java.util.concurrent.ThreadPoolExecutor$Worker.run
(ThreadPoolExecutor.java:673)
E/AndroidRuntime( 410): at java.lang.Thread.run(Thread.java:
935)
E/ ( 410): VM won't let us allocate 65536 bytes
E/AndroidRuntime( 410): Uncaught handler: thread pool-8-thread-9
exiting due to uncaught exception
E/



OutOfMemoryError BitmapFactory.nativeDecodeByteArray inside Threads

by aditya marella » Wed, 17 Dec 2008 02:34:27 GMT


  too ran into this many times and my images are not on the disk they are
fetched from the network moreover none of my images exceed 5kb so i don't
understand why is it even trying to allocate 74752bytes.

11-26 15:40:34.967: ERROR/dalvikvm-heap(801): 74752-byte external allocation
too large for this process.
11-26 15:40:34.977: ERROR/(801): VM won't let us allocate 74752 bytes
11-26 15:40:35.277: DEBUG/AndroidRuntime(801): Shutting down VM
11-26 15:40:35.277: WARN/dalvikvm(801): threadid=3: thread exiting with
uncaught exception (group=0x40013e28)
11-26 15:40:35.287: ERROR/AndroidRuntime(801): Uncaught handler: thread main
exiting due to uncaught exception
11-26 15:40:35.537: ERROR/AndroidRuntime(801): java.lang.OutOfMemoryError:
bitmap size exceeds VM budget
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.graphics.Bitmap.nativeCreate(Native Method)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.graphics.Bitmap.createBitmap(Bitmap.java:343)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.View.buildDrawingCache(View.java:5219)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.View.getDrawingCache(View.java:5112)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1355)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1192)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.widget.AbsListView.dispatchDraw(AbsListView.java:1125)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.widget.ListView.dispatchDraw(ListView.java:2778)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.View.draw(View.java:5422)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1420)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1192)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1418)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1192)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.View.draw(View.java:5329)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.widget.FrameLayout.draw(FrameLayout.java:324)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1420)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1192)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1418)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1192)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.drawChild(ViewGroup.java:1418)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.ViewGroup.dispatchDraw(ViewGroup.java:1192)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.View.draw(View.java:5329)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.widget.FrameLayout.draw(FrameLayout.java:324)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1701)
11-26 15:40:35.537: ERROR/AndroidRuntime(801): at
android.view.Vi


Sponsored Links