September 21st, 2011, 09:32 PM
|
#1 (permalink)
|
|
Junior Member
Join Date: Jul 2011
Posts: 27
Device(s):
Thanks: 9
Thanked 2 Times in 2 Posts
|
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:4 68)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.graphics.Bitmap.createBitmap(Bitmap.java:4 35)
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(Activi ty.java:3835)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.deliverResults(Activity Thread.java:3332)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.handleSendResult(Activi tyThread.java:3378)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread.access$2700(ActivityThr ead.java:123)
09-21 12:05:27.770: ERROR/AndroidRuntime(2350): at android.app.ActivityThread$H.handleMessage(Activit yThread.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.jav a: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$MethodAndArgsCa ller.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
|
|
|