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


Other Threads

1. Registering with the USB HID CLASS Driver

Hi All,

I have a typical scenario to handle here on hid class.

1. I have usb hid class report in userspace.
2. I need to send this usb hid report to the existing 'USB Hid class
driver in the kernel for parsing the report. In usual scenarios the
'USB Hid class driver' registers itself with the USB driver to receive
HID reports.

Part(1) above looks fine since I can have a character  driver to read
USB HID Reports from user space and get it to the kernel.
But, then how do I send this report, like the usb driver, to the USB
HID CLASS DRIVER for parsing.

Please let me know if you can help me out with this.

-Sunil

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

2. kmemtrace

I was trying to use the kmemtrace (enabled CONFIG_KMEMTRACE=y) in
defconfig. But I cannot see /sys/kernel/debug/kmemtrace location. Can
someone help me enable kmemtrace tool? Is it available on 2.6.32
kernel?

Thanks
-Harshad

-- 
unsubscribe: android-kernel+unsubscr...@googlegroups.com
website: 

3. How to detect orientation change in home screen widget?

4. About rotate screen use G-SENSOR

5. How to set text size and color in CheckBoxPreference

6. How to implement the type-to-search UI as in the built-in contacts app

7. How the security works in android