out of memory - Android OOM For Bitmap with image Capture -


i have been battling "memory leak" past 3 days non-stop , while have streamlined other parts of application problem has remained.

first trying do. firing intent image_capture extra_output save image file. display returned image scaled down order of 2, user, letting him select square portion of image. once selects it, taken activity lets him tag image text , such, , upload using httppost server.

right now, works great once! can go through , works, without problem. if try take picture however, out of memory exception. here logcat latest time it's happened

02-18 19:07:19.498: error/dalvikvm-heap(6385): 1040400-byte external allocation large process. 02-18 19:07:19.498: error/graphicsjni(6385): vm won't let allocate 1040400 bytes 02-18 19:07:19.498: debug/androidruntime(6385): shutting down vm 02-18 19:07:19.498: warn/dalvikvm(6385): threadid=1: thread exiting uncaught exception (group=0x4001d7f0) 02-18 19:07:19.518: error/androidruntime(6385): fatal exception: main 02-18 19:07:19.518: error/androidruntime(6385): java.lang.runtimeexception: unable start activity componentinfo{com.hitpost/com.hitpost.sharepicture}: android.view.inflateexception: binary xml file line #29: error inflating class <unknown> 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2663) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activitythread.handlelaunchactivity(activitythread.java:2679) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activitythread.access$2300(activitythread.java:125) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activitythread$h.handlemessage(activitythread.java:2033) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.os.handler.dispatchmessage(handler.java:99) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.os.looper.loop(looper.java:123) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activitythread.main(activitythread.java:4627) 02-18 19:07:19.518: error/androidruntime(6385):     @ java.lang.reflect.method.invokenative(native method) 02-18 19:07:19.518: error/androidruntime(6385):     @ java.lang.reflect.method.invoke(method.java:521) 02-18 19:07:19.518: error/androidruntime(6385):     @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:858) 02-18 19:07:19.518: error/androidruntime(6385):     @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) 02-18 19:07:19.518: error/androidruntime(6385):     @ dalvik.system.nativestart.main(native method) 02-18 19:07:19.518: error/androidruntime(6385): caused by: android.view.inflateexception: binary xml file line #29: error inflating class <unknown> 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.createview(layoutinflater.java:513) 02-18 19:07:19.518: error/androidruntime(6385):     @ com.android.internal.policy.impl.phonelayoutinflater.oncreateview(phonelayoutinflater.java:56) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:563) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.rinflate(layoutinflater.java:618) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.rinflate(layoutinflater.java:621) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.inflate(layoutinflater.java:407) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.inflate(layoutinflater.java:320) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.inflate(layoutinflater.java:276) 02-18 19:07:19.518: error/androidruntime(6385):     @ com.android.internal.policy.impl.phonewindow.setcontentview(phonewindow.java:198) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activity.setcontentview(activity.java:1647) 02-18 19:07:19.518: error/androidruntime(6385):     @ com.hitpost.sharepicture.oncreate(sharepicture.java:90) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.instrumentation.callactivityoncreate(instrumentation.java:1047) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.app.activitythread.performlaunchactivity(activitythread.java:2627) 02-18 19:07:19.518: error/androidruntime(6385):     ... 11 more 02-18 19:07:19.518: error/androidruntime(6385): caused by: java.lang.reflect.invocationtargetexception 02-18 19:07:19.518: error/androidruntime(6385):     @ android.widget.imageview.<init>(imageview.java:108) 02-18 19:07:19.518: error/androidruntime(6385):     @ java.lang.reflect.constructor.constructnative(native method) 02-18 19:07:19.518: error/androidruntime(6385):     @ java.lang.reflect.constructor.newinstance(constructor.java:446) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.view.layoutinflater.createview(layoutinflater.java:500) 02-18 19:07:19.518: error/androidruntime(6385):     ... 23 more 02-18 19:07:19.518: error/androidruntime(6385): caused by: java.lang.outofmemoryerror: bitmap size exceeds vm budget 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmap.nativecreate(native method) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmap.createbitmap(bitmap.java:468) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmap.createbitmap(bitmap.java:435) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmap.createscaledbitmap(bitmap.java:340) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmapfactory.finishdecode(bitmapfactory.java:488) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmapfactory.decodestream(bitmapfactory.java:462) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.bitmapfactory.decoderesourcestream(bitmapfactory.java:323) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.graphics.drawable.drawable.createfromresourcestream(drawable.java:697) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.content.res.resources.loaddrawable(resources.java:1709) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.content.res.typedarray.getdrawable(typedarray.java:601) 02-18 19:07:19.518: error/androidruntime(6385):     @ android.widget.imageview.<init>(imageview.java:118) 02-18 19:07:19.518: error/androidruntime(6385):     ... 27 more 

it failing on setcontentview of last activity, in displays picture once user, somehow not able display again.

i appreciate help!

updated have been testing issue on multiple phones, , 1 seems doing nexus 1 froyo. works on samsung captivate 2.1, doesn't crash in regard issue on moto milestone 2.1.

also need 500 x 500 image @ end can't scale down factor more 2.

see response @ bitmapfactory oom driving me nuts.

your bitmap data in native heap, not vm heap. explicit vm garbage collection have no effect.

the native heap garbage collected less / aggressively. approach have found work

  • monitor native heap (as per link above) make sure not hit oom exception
  • free bitmaps when not need them (which reclaim space in native heap) doing (as doing)

    mbitmap.recycle(); mbitmap = null;


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -