potter: init: set dalvik heap props based on detected RAM size

This commit is contained in:
Vachounet
2017-04-18 11:29:30 +02:00
parent 064c63fa30
commit 5bdfbe4550
2 changed files with 25 additions and 5 deletions

View File

@@ -27,7 +27,9 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <sys/sysinfo.h>
#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");
}
}