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. Emma Instrumentation Code and How it works

Hi,

I am new to this emma world! Just trying to figure out what code emma
injects to the class that is instrumented and where? I read in this
forum that Emma injects some byte code after each basic block. Can
anyone answer me the following questions

1) What exact byte code is injected at the end of each basic block?
2) What is the impact of those byte codes in term of performance,
security and JVM?
3) I saw someone said byte code injection changes the line numbers in
the class file and has some impact in the JVM in terms of variable
location, stack table etc. What are those impacts to JVM due to these
injections?
4) Is there any behavi{*filter*}change of instrumented classes while
interacting certain classes which are instrumented within same/
different package or using methods of other external or internal
classes which are not instrumented compare to their original class
behavior which earlier was not instrumented and worked fine?
5) Can any instrumented class cause improper behavior to the existing
application and what are those probable impacts?
6) Can we use certain instrumented class in production env and is
there any risk of malfunctioning of the application in production
system?
7) Is there any security issue using instrumented class in production?

-- 

2. filter html and alert baised on criteria entered

I'm trying to find a way to automatically search html code for a
criteria that shows up each time then bring the app to the front and
also send notification

-- 

3. Created files in external storage on Archos 5 invisible on Windows Explorer

4. Distinct query in managedQuery

5. Gallery not Recycling Views

6. Example "Tab Layout" wont work in "http://developer.android.com/resources/tutorials/views/hello-tabwidget.html"

7. Possible to have private authtoken stored for Account which has been created via AccountManager?