From 5325010486a13553a8597aab92f90abc141a25e8 Mon Sep 17 00:00:00 2001 From: Ian Rogers Date: Sun, 23 Sep 2012 16:38:03 -0700 Subject: [PATCH] Extra GC heap configuration parameters. Allows parameters to increase the maximum free size. b/6606849 Change-Id: Ia74ccdbb8e32954820e3bd26f441b2c2fac889f4 --- core/jni/AndroidRuntime.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp index 27684d72cb4c1..48fe7fa40136a 100644 --- a/core/jni/AndroidRuntime.cpp +++ b/core/jni/AndroidRuntime.cpp @@ -453,6 +453,9 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) char heapstartsizeOptsBuf[sizeof("-Xms")-1 + PROPERTY_VALUE_MAX]; char heapsizeOptsBuf[sizeof("-Xmx")-1 + PROPERTY_VALUE_MAX]; char heapgrowthlimitOptsBuf[sizeof("-XX:HeapGrowthLimit=")-1 + PROPERTY_VALUE_MAX]; + char heapminfreeOptsBuf[sizeof("-XX:HeapMinFree=")-1 + PROPERTY_VALUE_MAX]; + char heapmaxfreeOptsBuf[sizeof("-XX:HeapMaxFree=")-1 + PROPERTY_VALUE_MAX]; + char heaptargetutilizationOptsBuf[sizeof("-XX:HeapTargetUtilization=")-1 + PROPERTY_VALUE_MAX]; char extraOptsBuf[PROPERTY_VALUE_MAX]; char* stackTraceFile = NULL; bool checkJni = false; @@ -555,6 +558,27 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv) mOptions.add(opt); } + strcpy(heapminfreeOptsBuf, "-XX:HeapMinFree="); + property_get("dalvik.vm.heapminfree", heapminfreeOptsBuf+16, ""); + if (heapminfreeOptsBuf[16] != '\0') { + opt.optionString = heapminfreeOptsBuf; + mOptions.add(opt); + } + + strcpy(heapmaxfreeOptsBuf, "-XX:HeapMaxFree="); + property_get("dalvik.vm.heapmaxfree", heapmaxfreeOptsBuf+16, ""); + if (heapmaxfreeOptsBuf[16] != '\0') { + opt.optionString = heapmaxfreeOptsBuf; + mOptions.add(opt); + } + + strcpy(heaptargetutilizationOptsBuf, "-XX:HeapTargetUtilization="); + property_get("dalvik.vm.heaptargetutilization", heaptargetutilizationOptsBuf+26, ""); + if (heapmaxfreeOptsBuf[26] != '\0') { + opt.optionString = heaptargetutilizationOptsBuf; + mOptions.add(opt); + } + /* * Enable or disable dexopt features, such as bytecode verification and * calculation of register maps for precise GC.