0

I am working on Application which is based on lot of bitmaps, now the problem is that in some devices i am getting run time Exception during Application testing.

this might me due to Bitmap size exceeds VM Budget.

Now the issue is that i cant reduce the use of bitmap in Application.so what are the possible solutions.

I had tried following link, but no success.

http://voices.yahoo.com/android-virtual-machine-vm-out-memory-error-7342266.html

please help me.

3 Answers3

1
This Happens because calling invalidate() just redraw same bitmaps on to the canvas..
use garbage collector  just try to free memory when these bitmap getting overdraw this 
might help you...:-)
akash yadav
  • 349
  • 4
  • 14
0

Recycle bitmaps when not in use. Compress the bitmap to reduce memory usage. Have a look at this link. http://developer.android.com/training/displaying-bitmaps/load-bitmap.html.

Use a MAT Analyzer to check how much memory is used by bitmap.

Check the link. Talks about memory management and how to use MAT to find memory leaks. http://www.youtube.com/watch?v=_CruQY55HOk.

Try compressing btimap to use less memory.

Raghunandan
  • 132,755
  • 26
  • 225
  • 256
0

You can try load bitmap with different bitmap config. This may help reduce the size of the loaded bitmap object in the heap, by choosing a different profile. For e.g if you don't need alpha values to be retained, use RGB565 config.

Recyle bitmap; have a look at this, it's a good read.

You can specify

android:largeHeap="true"

in your manifest file. This will allow more heap to the application, but only if it's possible. Available form API 11 onward.

You can also try displaying a scaled down version to the user and allowing any manipulation if any(as default gallery viewer app does).

Also, do check that what you are getting is exactly a "VM budget exceeded due to bitmap" problem, because you yourself are not so sure.

Master Chief
  • 2,520
  • 19
  • 28