4

We have an app with lots of bitmaps in memory. It keeps failing with

java.lang.OutOfMemoryError: bitmap size exceeds VM budget

errors. It's possible that we are genuinely using too much memory; it's possible that we are leaking memory; it's also possible that we aren't doing anything wrong, and heap fragmentation is what's killing us. (Since Android's garbage collector doesn't relocate live blocks, we could have megabytes free and be unable to allocate 50K.)

Is there any way to rule out fragmentation? I've looked for something like maxAvail/memAvail, but haven't spotted anything apposite.

trincot
  • 317,000
  • 35
  • 244
  • 286
Jon Shemitz
  • 1,235
  • 13
  • 29
  • Check out http://stackoverflow.com/questions/1955410/bitmapfactory-oom-driving-me-nuts/5493182 – Torid Dec 02 '11 at 23:20
  • Thank you, @Torid. That approach may be what we have to do ... if it does turn out that we are genuinely using too much memory. At this point, though, we're still trying to figure out which problem we have. – Jon Shemitz Dec 02 '11 at 23:34

1 Answers1

1

I would look into examining the heap via MAT. The Eclipse Memory Analyzer will help you determine which of your proposed issues you actually have.

There was a talk at Google I/O 2011 that covered some basics on the topic of memory management and debugging. You can watch it online here: http://www.youtube.com/watch?v=_CruQY55HOk&feature=relmfu

smith324
  • 13,020
  • 9
  • 37
  • 58
  • Thank you. I'll get back to this ASAP, and either accept your answer or post further comments. – Jon Shemitz Dec 12 '11 at 22:27
  • 2
    When MAT shows you using 5M of 32 or 64 and you're getting OOM on a 2M allocation, it's hard to conclude that it';s anything but fragmentation. – Jon Shemitz Apr 05 '12 at 21:50