Custom heap size in Android platform?

The software development team in our graduation project asked to increase the heap size for each process in Android. They said that the default is 16 MB, which is not enough for them. How can I adjust 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 change?

+4
source share
2 answers

I got this answer through the Android platform mailing list.

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

For example, to do this 32 MB, you can do below

gDvm.heapSizeMax = 32 * 1024 * 1024;

Another suggested approach is to update system.prop

Regards, Muthu Subramaniam

+1
source

In your onCreate method in your activity or, if you want all your applications in the package, the onCreate application custom object, add

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

Edit: Also note that Android will automatically increase the heap size if it needs more. Therefore, although the default value may be 16, if it needs more, it will increase it. However, this can lead to a small malfunction in a real-time situation, which is bad. Therefore, if you know that this will last up to 16 years, do it in advance.

+3
source

Source: https://habr.com/ru/post/1316722/


All Articles