I am trying to understand why my application uses so much memory. I often see that it uses from 15 to 18 MB, which is significantly higher than I expected. I looked at the heap size through DDMS and saw this:

It looked a little suspicious because my application does not deal with large images at all. In fact, the total amount of drawings in my application is about 250 KB. So I created a bunch of heaps and used MAT to determine where all this was happening. bytes [] were the biggest consumer, so I turned around and noticed the following:

I have absolutely no idea why sPreloadedDrawables is responsible for such a high heap size. I also do not know how to determine the root cause or how to fix it.
Where do I go next? My application works mainly in the background through services that do not deal with image data at all. I have actions that the user can use, but again they use small drawings that do not explain such a large heap size. I also checked for any unpleasant cases of activity leaks, etc., but did not find them.
EDIT: I noticed that the heap size is significantly lower when running in the emulator. This is pretty confusing.: /
android memory-management ddms
Glitch Mar 11 '12 at 8:13 2012-03-11 08:13
source share