From 8baf2c2b50883f3af497ca872fe6b435f3902444 Mon Sep 17 00:00:00 2001 From: Steven Moreland Date: Fri, 16 Oct 2020 01:00:30 +0000 Subject: Zygote: disable heap 0'ing in apps. Uninitialized memory back by popular demand. We have trialed heap 0'ing (malloc is calloc) in Android for a few days in all processes, but there are a couple of signs that doing this in app processes may be too ambitious. Bug: 170891666 Bug: 131355925 Test: boot, see disable logs Change-Id: I60563712c8af459f2f847b4598477b042a05d7ea --- core/jni/com_android_internal_os_Zygote.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index dadf08f2cc90..95c295a4784c 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -647,6 +648,13 @@ static void PreApplicationInit() { // Set the jemalloc decay time to 1. mallopt(M_DECAY_TIME, 1); + + // Avoid potentially expensive memory mitigations, mostly meant for system + // processes, in apps. These may cause app compat problems, use more memory, + // or reduce performance. While it would be nice to have them for apps, + // we will have to wait until they are proven out, have more efficient + // hardware, and/or apply them only to new applications. + process_disable_memory_mitigations(); } static void SetUpSeccompFilter(uid_t uid, bool is_child_zygote) { -- cgit v1.2.3-59-g8ed1b