Increasing Java Heap size in Android from source code

Under /frameworks/base/core/jni/ there is a file called AndroidRuntime.cpp where the Dalvik VM parameters are set. You can do a search over the file for “dalvik.vm.heapsize” and you will find out something like this:

* The default starting and maximum size of the heap. Larger
* values should be specified in a product property override.
strcpy(heapstartsizeOptsBuf, "-Xms");
property_get("dalvik.vm.heapstartsize", heapstartsizeOptsBuf+4, "4m");
opt.optionString = heapstartsizeOptsBuf;
strcpy(heapsizeOptsBuf, "-Xmx");
property_get("dalvik.vm.heapsize", heapsizeOptsBuf+4, "16m");
opt.optionString = heapsizeOptsBuf;

change “16m” for any other value, taking into account, the available memory in your device. For example, setting the heap size to 48m it is a good choice in a Beagleboard xM or Beaglebone Black, both with nearly 512Megabytes of RAM.