3

How can I reduce the allocated heap of my application,DDMS in Eclipse shows that

Heap Size:62.3MB

Allocated:44.6MB

Used:70%

I Also want to know does PNG images allocate a huge size ??Because I deleted a PNG Button from my application and as a result heap allocation was reduced.

Is it bad to use JPG for Backgrounds and PNG for Buttons .

user1928775
  • 355
  • 1
  • 5
  • 15

1 Answers1

1

AFAIK images allocate memory in function of their resolution and their bit depth. So try to use different images for different densities and try to avoid when your requirements allow it loading huge images as backgrounds.

Luciano Rodríguez
  • 2,239
  • 3
  • 19
  • 32
  • All my images is 441 Bits per inch is it bad ?? – user1928775 Dec 14 '13 at 13:45
  • 1
    height x width x 4 bytes. It doesn't matter how your store them, only the size of the bitmap on the heap. it's entirely possible to have a 500k BMP which uses less memory than a 50K JPG. – Simon Dec 14 '13 at 13:47
  • And What image property affects the heap size ?? – user1928775 Dec 14 '13 at 13:53
  • AFAIK the resolution of the image and the bit depth. Make different images for different densities and store them in different folders according to http://developer.android.com/guide/practices/screens_support.html and http://developer.android.com/guide/practices/tablets-and-handsets.html – Luciano Rodríguez Dec 14 '13 at 14:12
  • Can you explain me what exactly these two terms mean Heap Size:62.3MB Allocated:44.6MB ALso if after some modification Heap Size increases by say 10MB, then is it good or bad? – Ankit Bansal Dec 19 '13 at 04:27
  • Heap size is the maximum amount of memory your application can allocate. Allocated is the memory that your application is using. Check http://stackoverflow.com/questions/10677850/android-understanding-heap-sizes for an extensive answer. If you are having problems with memory be sure to use specific images for different densities. It won't happen anything if your s4 loads an image desiged to show on ldpi devices, but in reverse it will be a problem. Reduce bit depth too and if this isn't enough set android:largeHeap="true" in your manifest, under application tag. – Luciano Rodríguez Dec 19 '13 at 08:03