summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Wailes <chriswailes@google.com>2020-01-29 23:41:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2020-01-29 23:41:25 +0000
commit53b77b57f4676a1ccd4060ebf007f99b6fdf09fa (patch)
tree095488e9faa86e0a91d0d08b1205d32f90d82cc4
parent0373c4e61343801a88af76fc5e8a08d8877b1645 (diff)
parent7699d61bc545f236428869690653b4e2a5c804f8 (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 4b969ece2e15..1ea7d6144356 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -1084,6 +1084,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) {