bitmap size exceeds Vm budget error android

Solution 1:

I also had the same problem OOME because of bitmaps.

When orientation changes from PORTRAIT to LANDSCAPE and vice-versa, the previous UI is completely discarded, and a new UI is loaded and displayed, In this case if you are using many bitmaps in your app, you need to release them at proper places.

To check the orientation of your device, please see this: Check orientation on Android phone

In your case, you need to clear bitmaps during orientation change.

On above link you can found, how to get the current orientation. So on each orientation change, call your above code that cleans up the bitmaps.

Now, when we check the logcat, there is always a log comes up saying GC_, but I could not understand that, so I found an amazing doc on memory leak issue: http://codelog.dexetra.com/getting-around-android-memory-blues

The above link is very useful for your problem.

Now, the OOME occurs when there is memory leak in your app., so to check that, please install the MAT for eclipse. You can find it at: http://www.eclipse.org/mat/downloads.php

Its a bit complicated software but as you go through it, you will understand, its pretty useful software.

Even if this doesn't solves your problem, use the WeakReference for bitmaps.

Please refer this link: How to use WeakReference in Java and Android development?

If I get know some more info, I will update this post.

Please update your post, if you get solution to your problem.

Thank you :)