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. Android RIL / GSM Parameter

Hello

We are actually trying to develop an Android app which should record
as much GSM-Parameter as possible during a call. After the call it ask
the user some questions depending on the type of call end. (Signal
Lost, normal local hangup, remote hangup, ...)

We are not allowed to root the phone as we d'like to deploy the app to
user which have no idea from android...

What we've already found out:

- The PhoneApp knows the Disconnect-Cause
-> Unfortunately we are not allowed to access the PhoneApp-Process
neither the internal telephony-API which the PhoneApp uses...

- We tried it with the PhoneStateListener to get the current
SignalStrength/BitErrorRate and the PhoneState (OFF_HOOK/IDLE/RINGING)
-> Unfortunately it is not possible to get the Signal Strength at a
specific time. The BiterrorRate does always return -1, which is
useless!
-> We know when the call ends (OFF_HOOK -> IDLE). But no idea why?

- Connect do RIL-Daemon
-> Unfortunately it is not allowed to connect to the RIL-Deamon except
from the Phone-Process!

- Use the oemRequest-Functionality on the RIL which is used by the
fieldTest-Apps from HTC/Samsung...
-> Unfortunately we've no access to this function on a non rooted
phone...

- Run our app in the Phone-Process
-> Unfortunately this is a very bad idea.. and as we don't have the
appropriate sign-key not possible...

So do you have any idea how we could implement this functionality?

Best Regards
Stefan


-- 

2. How to wrap multi APK into one Installation package

Now have some APKs, and want wrap these APKs into one installation
package.
How to do it?

-- 

3. SMTP Features - Android - API 3

4. How to get notified when there's an incoming call or SMS?

5. what dialog to use for volume adjustment?

6. How to email uncaught exceptions?

7. User Agent String for Google TV