Android memory allocation

As with any Java VM, the heap memory will automatically grow to the max size. But, bitmaps are allocated outside the VM, so you don’t “see” them easily in the stats. The best thing you can do is make sure you don’t use large bitmaps, or scale them down using
http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html

From Eclipse you can generate a heap dump when you are on Android 1.6 or up and you can analyze the dump with Eclipse MAT.

Generally you can’t control the max heap size on a real device, unless you are working with custom hardware or firmware.

There should be an article at developer.android.com on dumping the heap on 1.6, but I’m unable to find it. 🙁

Edit
Also, I have to mention that you can request more memory for applications by using

android:largeHeap=”true”

in the manifest. But this is highly ill-adviced as most applications do not need this.

Leave a Comment