Merge "Purge unused native memory before Zygote fork events" am: 0b242c8d77 am: c1fa69a24d
Change-Id: I9f7f554ae0936873a8e2b365be092fe3ac6146bb
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index 486df62..a09c0b3 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -1000,6 +1000,13 @@
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) {