1

Alright, I am not typically one to ask for help as I usually prefer to find answers on my own, but unfortunately I seem unable to do that.

I am messing around with live wallpapers for android 2.1+ Things went pretty well until a ways in I started getting a OOM error:

Java.lang.OutOfMemoryError: bitmap size exceeds VM budget

Ok - I did my research and found out that I surely have a memory leak somewhere. So I read up on how to analyze such problems, opened up the DDMS and did a Heap dump. the Heap size usually runs around 4.5-5mb in size and never more than 60% full. This didn't make sense, because I checked the running services on my development phone, and it reported my process as using anywhere from 35-42mb of memory.

I'm not asking for anyone to find my Leak as that would require lots of code etc. Just to explain how to properly analyze my memory usage, since I seem to be utterly dumbfounded as to what is going on.

trincot
  • 317,000
  • 35
  • 244
  • 286

2 Answers2

0

I'm guessing you already did this, but just in case... did you examine the line that triggered the OutOfMemoryError? How big is the bitmap you are trying to create?

If it is a leak here is an article that might help you analyze a heap dump (you won't have to use eclipse despite the article title):

Android ==> Memory Analysing ==> Eclipse memory analyzer?

Good Luck.

Community
  • 1
  • 1
satur9nine
  • 13,927
  • 5
  • 80
  • 123
0

Thanks satur9nine, I actually did some more digging after posting this and finally got a grasp of what was going on (of course that was after I posted the question, go figure).

I discovered that the memory usage reported in the services manager in android is referred to as the Native Heap. This is the Heap size + bitmaps (among other things possibly?). But I was still a bit confused as to why it was 40+ MB at times, when the images I were loading were only ~900 KB. When it clicked that images no longer stay compressed when loaded in to memory. So my loading of approximately 30 small PNG's was taking up a massive amount of memory.

I was cycling through each of these PNG's to make a Rain animation. I didn't realize at the time that was a bad strategy. Once I realized that was the problem, I scrapped it and Wrote myself a simple little "Particle System" To generate a nice rain animation with just one particle icon loaded in to memory!

  • Glad you solved your problem. I'm not surprised it wasn't really a leak. Usually you have to try hard to leak memory in Java. – satur9nine Jan 02 '11 at 19:13