• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps OutOfMemoryError when adding photo from gallery ?

HI,
I add photo from gallery after 3 - 4 photos added application is crashing with "OutOfMemoryError: bitmap size exceeds VM budget". I dont know why it is happening. While after used bitmap variable I am recycle that bitmap variable.

Example:

==========================================================
09-21 12:05:27.760: ERROR/AndroidRuntime(2350): Uncaught handler: thread main exiting due to uncaught exception
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.graphics.Bitmap.nativeCreate(Native Method)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at com.mobigen.iplant.IPlant.onActivityResult(IPlant.java:355)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.Activity.dispatchActivityResult(Activity.java:3835)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.deliverResults(ActivityThread.java:3332)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3378)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.access$2700(ActivityThread.java:123)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1900)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.os.Handler.dispatchMessage(Handler.java:99)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.os.Looper.loop(Looper.java:123)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.main(ActivityThread.java:4370)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at java.lang.reflect.Method.invokeNative(Native Method)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at java.lang.reflect.Method.invoke(Method.java:521)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at dalvik.system.NativeStart.main(Native Method)


Solution I tried for it
==================
1>
BitmapFactory.Options options = new BitmapFactory.Options();
options.inTempStorage = new byte[16*1024];
bitmapImage = BitmapFactory.decodeFile(path,opt);

2>
bm.recycle();

But, I tried that, and this approach is not working.

What is the proper solution for it ?

Please help me out.

Thanks in advance,
Andy
 
Back
Top Bottom