Ledbelly2142
Aspiring developer
Profile
Posts: 80
Reg: Aug 04, 2012
Reno
6,750
09/15/12 12:03 PM (13 years ago)

Bitmap size exceeds VM budget error... is that in pixels or KB?

Working with the image plugin, trying to pinpoint why it keeps crashing in Android. I was using a .jpg and got some strange errors (I'm clueless), changed the image to a .png and my app seemed to work faster, crash less--but still crash. My png image is the correct pixel size (defined by the Menu with Image plugin), it's 340 KB and a web reference (not in project file). Is my graphic too large in KB? or because the AVD is a smaller screen, should I use a smaller area sized (pixel x pixel) graphic? Here is the error when the app crashed (from LogCat) The first error I got was: 09-15 18:34:14.335: E/dalvikvm-heap(375): 2211840-byte external allocation too large for this process. 09-15 18:34:14.345: E/GraphicsJNI(375): VM won't let us allocate 2211840 bytes So the app is requesting a 2.1 Megabyte file... Not sure where that is coming from. Then crashed: 09-15 18:34:14.375: E/AndroidRuntime(375): FATAL EXCEPTION: main 09-15 18:34:14.375: E/AndroidRuntime(375): java.lang.OutOfMemoryError: bitmap size exceeds VM budget 09-15 18:34:14.375: E/AndroidRuntime(375): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:459) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.graphics.drawable.Drawable.createFromStream(Drawable.java:657) 09-15 18:34:14.375: E/AndroidRuntime(375): at com.HappenMake.BT_fileManager.getDrawableFromCache(BT_fileManager.java:295) 09-15 18:34:14.375: E/AndroidRuntime(375): at com.HappenMake.WB_screen_menuImage.onCreate(WB_screen_menuImage.java:228) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.app.ActivityThread.access$2300(ActivityThread.java:125) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.os.Handler.dispatchMessage(Handler.java:99) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.os.Looper.loop(Looper.java:123) 09-15 18:34:14.375: E/AndroidRuntime(375): at android.app.ActivityThread.main(ActivityThread.java:4627) 09-15 18:34:14.375: E/AndroidRuntime(375): at java.lang.reflect.Method.invokeNative(Native Method) 09-15 18:34:14.375: E/AndroidRuntime(375): at java.lang.reflect.Method.invoke(Method.java:521) 09-15 18:34:14.375: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 09-15 18:34:14.375: E/AndroidRuntime(375): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 09-15 18:34:14.375: E/AndroidRuntime(375): at dalvik.system.NativeStart.main(Native Method) Then I get force quite messages in the AVD, that I have to press multiple times (likely because the AVD is out of configured memory). -Led
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
09/15/12 07:02 PM (13 years ago)
I have the same issue right now. and wondering what the solution might be as well
 
Ledbelly2142
Aspiring developer
Profile
Posts: 80
Reg: Aug 04, 2012
Reno
6,750
like
09/15/12 07:28 PM (13 years ago)
I wounded if installing the graphic I the scr dir and calling it locally from the app, rather than calling it from a web link (e.g. Www.buzztouch.com/blablabla)? I want to be able to change the graphic in the future... But my understanding is that once you download the graphic the first time, it's cached in the Android device. So it really shouldn't make a difference. -Led
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
09/16/12 11:22 AM (13 years ago)
I had an 'out of memory' problem on Android that I just fixed by reducing the size of a graphic that worked fine on my iPhone app. In my case, the problem was a button image, but it might be a related issue. My suggestion woukd be to look closely at your images, start with the largest ones and shrink them as much as you can.
 
Ledbelly2142
Aspiring developer
Profile
Posts: 80
Reg: Aug 04, 2012
Reno
6,750
like
09/16/12 12:56 PM (13 years ago)
What is a good image size (in KB) for apps? I suspect it's different for Apple and Android. Is it as small as you can get away with or is there a good target size, say 50K or 100K? Thanks, -Led
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
09/16/12 01:00 PM (13 years ago)
I shrank mine 35% in photoshop and now i have no issues.
 
Ledbelly2142
Aspiring developer
Profile
Posts: 80
Reg: Aug 04, 2012
Reno
6,750
like
09/16/12 01:09 PM (13 years ago)
Fusionmtx, From what to what? in K or in pixel size? Thanks, -Led
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
09/16/12 01:09 PM (13 years ago)
I did it by percentage
 
Ledbelly2142
Aspiring developer
Profile
Posts: 80
Reg: Aug 04, 2012
Reno
6,750
like
09/16/12 01:12 PM (13 years ago)
Please forgive me, Im not very familiar with Photoshop. When you shrink it by percentage, do you shrink it in memory (KB) and/or pixel size (area of image)? Thanks, Greg
 
Ledbelly2142
Aspiring developer
Profile
Posts: 80
Reg: Aug 04, 2012
Reno
6,750
like
09/16/12 01:13 PM (13 years ago)
Please forgive me, Im not very familiar with Photoshop. When you shrink it by percentage, do you shrink it in memory (KB) and/or pixel size (area of image)? Thanks, Greg
 
fusionmtx
Android Fan
Profile
Posts: 178
Reg: Jun 15, 2011
Orlando
2,180
like
09/16/12 01:16 PM (13 years ago)
when you do it by percentage it takes away in pixels
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.