Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.OutOfMemoryError: bitmap size exceeds VM budget [duplicate]

Tags:

android

I m fetching photo from gallery and display in ImageView. But my issue is sometime is working fine and sometime is geting error. Error is Bitmap size exceeds VM budget..

Log Error..

04-01 10:14:57.098: ERROR/AndroidRuntime(12863): java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at androidexperts.wp7.facebook.WP7FB.sharePhotoDialog(WP7FB.java:200)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at androidexperts.wp7.facebook.WP7FB.onActivityResult(WP7FB.java:269)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.Activity.dispatchActivityResult(Activity.java:3890)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.deliverResults(ActivityThread.java:3511)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.handleSendResult(ActivityThread.java:3557)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.access$2800(ActivityThread.java:125)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2063)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.os.Looper.loop(Looper.java:123)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at android.app.ActivityThread.main(ActivityThread.java:4627)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at java.lang.reflect.Method.invokeNative(Native Method)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at java.lang.reflect.Method.invoke(Method.java:521)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
04-01 10:14:57.098: ERROR/AndroidRuntime(12863):     at dalvik.system.NativeStart.main(Native Method)            
like image 943
Niranj Patel Avatar asked Apr 01 '11 04:04

Niranj Patel


1 Answers

Use BitmapFactory.Options.inSampleSize and set it to a value >1 which will scale it down.

like image 159
Piyush Patel Avatar answered Oct 21 '22 07:10

Piyush Patel