2

I'm working with Android on eclipse and while testing the code, I seemed to notice the heap raising to 44MB. I'm searching for the variable that I'm keeping alive and I can't seem to find it for a few days. While looking in the heap (DDMS -> Heap) I get the following:

enter image description here


I tried clicking the "Dump HPROF file" as showed in here, but I don't get the save file dialog and I can't analysis it. so I'm trying to override it untill I get a new computer..


I'm running Android eclipse on Windows 7.
EDIT: The problem was the ImageViews I keep; I have two images that I set resource via the code with an image of 0.5MB. My question is: is it possible to add ImageViews without growing the heap by that much? and how come 2 images of 0.5MB cause 40MB grow heap?

user2558461
  • 281
  • 1
  • 6
  • 21
  • 1
    for me the background images took a lot of memory, as first step try to remove, you should be under 10m without whistles and bells –  Aug 02 '13 at 05:34
  • This thread http://stackoverflow.com/q/3112671/1321873 should be able to lead you the right direction – Rajesh Aug 02 '13 at 06:16

1 Answers1

1

To answer your edited-in question, your "0.5MB" images are probably compressed. Jpeg or PNG, most likely.

That doesn't matter once they get decoded. What matters then are the dimensions of the image and the bitmap format being used. A typical bitmap in Android is ARGB_8888, which is 32 bits(4 bytes) per pixel.

That means for every pixel(w*h), it costs 4 bytes of space. Looking at the max size(~15MB), It looks like your image is probably about 1600x1200, or around 2MP.

That's 1600 * 1200 * 4 = 15360000, or ~15MB for each image.

For most things, you shouldn't need an image that large on a mobile device. I don't know your application, but if you don't need it that large, you should look into Loading Large Bitmaps Efficiently.

Geobits
  • 22,218
  • 6
  • 59
  • 103