views:

195

answers:

2

The software team in our graduation project asked for increasing the heap size per process in Android. They said that the default is "16MB" which isn't sufficient for them. How could I custom the size?

I found a commented line in the file: /acme/my_board/BoardConfig.mk in my android source code:

# USE_CUSTOM_RUNTIME_HEAP_MAX := "64M"

Is that what I need to edit??

A: 

In your onCreate method in your activity, or, if you want it for all your applications in a package, a custom Application object's onCreate, add

dalvik.system.VMRuntime.getRuntime().setMinimumHeapSize(yournumberhere);

Edit: Also note that Android will automatically increase the heap size if it needs more. So even though the default might be 16, if it needs more, it will increase it. However that might make a little hickup in a real-time situation which is bad. Therefore if you know it will go over 16 it's good to do it before-hand.

Moncader
It's also worthwhile to note that this isn't a sustainable method for increasing an application heap size, refer to http://developer.android.com/reference/dalvik/system/VMRuntime.html ... This class is deprecated.this is an internal Dalvik class that is not appropriate for general use. It will be removed from the public API in a future release.
Quintin Robinson
A: 

I got that answer through android-platform mailing list

You can change platform/dalvik/vm/Init.c

For example to make it 32MB, you can do below

gDvm.heapSizeMax = 32 * 1024 * 1024;

Another suggested approach is to update your system.prop

Regards, Muthu Subramaniam

Osama Gamal