Search code examples
androidheap-memorydalvik

Setting Application Specific Max Heap Size for the Android Dalvik VM


Is it possible to set an application-specific max heap size (the dalvik.vm.heapsize property) instead of using the same maximum heapsize for all VM's running on an Android device? I know I can set a new dalvik heapsize by modifying the device's AndroidRuntime.cpp as root, but based on what I have read, because Android only initializes the VM once and then forks subsequent VM instances all VM's running on the device have the same dalvik.vm.heapsize property. Am I understanding this correctly, and is there any way around it?


Solution

  • The only built-in way to change heap size of an app is by setting android:largeHeap="true" in the Manifest.xml. This will generally increase heap size from 48 to 128.

    Keep in mind this approach will only work on 3.0+ devices.