From 5bdfbe45504e2cd65a298d9d70b2bb67283fe4b8 Mon Sep 17 00:00:00 2001 From: Vachounet Date: Tue, 18 Apr 2017 11:29:30 +0200 Subject: [PATCH] potter: init: set dalvik heap props based on detected RAM size --- init/init_potter.cpp | 25 +++++++++++++++++++++++++ system.prop | 5 ----- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/init/init_potter.cpp b/init/init_potter.cpp index 510d4ff..32cc91a 100644 --- a/init/init_potter.cpp +++ b/init/init_potter.cpp @@ -27,7 +27,9 @@ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include +#include #include "vendor_init.h" #include "property_service.h" @@ -49,6 +51,7 @@ void num_sims() { void vendor_load_properties() { + struct sysinfo sys; std::string platform = property_get("ro.board.platform"); if (platform != ANDROID_TARGET) @@ -74,5 +77,27 @@ void vendor_load_properties() property_set("ro.hw.ecompass", "false"); property_set("ro.hw.nfc", "true"); } + + sysinfo(&sys); + + if (sys.totalram > 3072ull * 1024 * 1024) { + property_set("dalvik.vm.heapstartsize", "8m"); + property_set("dalvik.vm.heapgrowthlimit", "384m"); + property_set("dalvik.vm.heapsize", "1024m"); + property_set("dalvik.vm.heapminfree", "4m"); + property_set("dalvik.vm.heapmaxfree", "16m"); + } else if (sys.totalram > 2048ull * 1024 * 1024) { + property_set("dalvik.vm.heapstartsize", "8m"); + property_set("dalvik.vm.heapgrowthlimit", "288m"); + property_set("dalvik.vm.heapsize", "768m"); + property_set("dalvik.vm.heapminfree", "512k"); + property_set("dalvik.vm.heapmaxfree", "8m"); + } else { + property_set("dalvik.vm.heapstartsize", "16m"); + property_set("dalvik.vm.heapgrowthlimit", "192m"); + property_set("dalvik.vm.heapsize", "512m"); + property_set("dalvik.vm.heapminfree", "2m"); + property_set("dalvik.vm.heapmaxfree", "8m"); + } } diff --git a/system.prop b/system.prop index 6a11716..3572b0c 100644 --- a/system.prop +++ b/system.prop @@ -77,11 +77,6 @@ ro.core_ctl_max_cpu=4 ro.core_ctl_min_cpu=2 # Dalvik -dalvik.vm.heapgrowthlimit=192m -dalvik.vm.heapmaxfree=8m -dalvik.vm.heapminfree=512k -dalvik.vm.heapsize=384m -dalvik.vm.heapstartsize=8m dalvik.vm.heaptargetutilization=0.75 # Display