开发者

Custom Heap Size in Android Platform?

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/Bo开发者_如何学PythonardConfig.mk in my android source code:

# USE_CUSTOM_RUNTIME_HEAP_MAX := "64M"

Is that what I need to edit??


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜