1

Possible Duplicate:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget

I have been getting this java.lang.OutOfMemoryError: bitmap size exceeds VM budget error from long time.I have many images(png's) which i am using in the application.The total size of all the images would be in Kb's. I went across various post related to this topic but they are related to devices.I am encountering this problem in emulator rather than any device, its working perfectly fine on all the device i have tested .What can be done for this problem.

11-08 12:18:53.259: E/AndroidRuntime(1626): FATAL EXCEPTION: main
11-08 12:18:53.259: E/AndroidRuntime(1626): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.curious.solutions.finalautoistdiary/com.curious.solutions.finalautoistdiary.ServiceAdd}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.os.Looper.loop(Looper.java:130)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.main(ActivityThread.java:3683)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Method.invokeNative(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Method.invoke(Method.java:507)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at dalvik.system.NativeStart.main(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.createView(LayoutInflater.java:518)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.parseInclude(LayoutInflater.java:684)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:619)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.Activity.setContentView(Activity.java:1657)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at com.curious.solutions.finalautoistdiary.ServiceAdd.onCreate(ServiceAdd.java:77)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-08 12:18:53.259: E/AndroidRuntime(1626):     ... 11 more
11-08 12:18:53.259: E/AndroidRuntime(1626): Caused by: java.lang.reflect.InvocationTargetException
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Constructor.constructNative(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.LayoutInflater.createView(LayoutInflater.java:505)
11-08 12:18:53.259: E/AndroidRuntime(1626):     ... 23 more
11-08 12:18:53.259: E/AndroidRuntime(1626): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.content.res.Resources.loadDrawable(Resources.java:1709)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.View.<init>(View.java:1951)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.View.<init>(View.java:1899)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.view.ViewGroup.<init>(ViewGroup.java:286)
11-08 12:18:53.259: E/AndroidRuntime(1626):     at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
11-08 12:18:53.259: E/AndroidRuntime(1626):     ... 26 more
Community
  • 1
  • 1
sankettt
  • 2,387
  • 4
  • 23
  • 31
  • could you post some related code and stack trace? – dumbfingers Nov 08 '12 at 09:53
  • At most, this exception is thrown when using bitmap manipulation in the UI Thread. You can workaround that by opening/manipulation Bitmaps in a Runnable – Andreas Nov 08 '12 at 09:54
  • Here you go: [java.lang.OutOfMemoryError: bitmap size exceeds VM budget](http://stackoverflow.com/search?q=java.lang.OutOfMemoryError%3A+bitmap+size+exceeds+VM+budget) – Paresh Mayani Nov 08 '12 at 09:59
  • I am loading all the images from drawable and in xml file so Bitmaps i am quite confused about it. can u explain in bit details – sankettt Nov 08 '12 at 09:59
  • This has been asked dozens of times before. – pgsandstrom Nov 08 '12 at 10:01
  • @PareshMayani i visited http://stackoverflow.com/questions/7108169/bitmap-size-exceeds-vm-budget-error-on-android this question and went through it in details but then its regarding images and i have small pngs which hardly eat up 1 mb of memory so why this issue when android provides 16 mb for each app – sankettt Nov 08 '12 at 10:02
  • @pgsandstrom though it has been asked no proper solution .. i have cleaned the project as per some of the solutions and reset the adb as well but no use after it moves from 1 activity to other it gives me the error.. ! thats why i have to post it again – sankettt Nov 08 '12 at 10:04
  • Loading from where? Local or Web? Are you facing issue just because of your code? What code you are trying for loading images? – Paresh Mayani Nov 08 '12 at 10:06
  • i am loading all the locally images from `drawable` folder and most of the most of them are there in `XML` just where the images are supposed to be changed at runtime i am using `img_services.setImageResource(img_services.getResources().getDrawable(R.drawable.services2));` – sankettt Nov 08 '12 at 10:08

0 Answers0