summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2020-01-30 17:13:11 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-01-30 17:13:11 +0000
commit0b242c8d77c329e1c3bc28475e86120026212b99 (patch)
tree5c597014102d68fa1c26bc307fdc58678fb6381c
parent3e6f7019804e92e8721a7cd8de8f075917a977b5 (diff)
parentaa0932d79a776e7613fbc0fd3faf697d06b5d26f (diff)
Merge "Purge unused native memory before Zygote fork events"
-rw-r--r--core/jni/com_android_internal_os_Zygote.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 486df621f4f1..a09c0b38eb2d 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -1000,6 +1000,13 @@ static pid_t ForkCommon(JNIEnv* env, bool is_system_server,
android_fdsan_error_level fdsan_error_level = android_fdsan_get_error_level();
+ // Purge unused native memory in an attempt to reduce the amount of false
+ // sharing with the child process. By reducing the size of the libc_malloc
+ // region shared with the child process we reduce the number of pages that
+ // transition to the private-dirty state when malloc adjusts the meta-data
+ // on each of the pages it is managing after the fork.
+ mallopt(M_PURGE, 0);
+
pid_t pid = fork();
if (pid == 0) {