summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Christopher Ferris <cferris@google.com> 2023-02-28 12:51:03 -0800
committer Christopher Ferris <cferris@google.com> 2023-02-28 12:51:03 -0800
commit571aa6fb494621acb178c42a7a70f64e7c6f6e7d (patch)
treea9980eb93df9cf599a9b5825fd3e2e512c3d7bae
parentae41acbe90c5a33c24084db4f93e3072d95df0db (diff)
Switch to purge all unused memory to kernel.
The new option purges all memory, but could take some extra time. However, there isn't much memory in the zygote so this should not incur much extra time during the purge operation. Bug: 243851006 Test: Verified that the zygote and zygote 64 on oriole reduce the Test: RSS by about 300K on average. Change-Id: Ic5eac43813163efb2c049ed280c2f15a89c3fa18
-rw-r--r--core/jni/com_android_internal_os_Zygote.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp
index fad9e0e79899..06e66d63de48 100644
--- a/core/jni/com_android_internal_os_Zygote.cpp
+++ b/core/jni/com_android_internal_os_Zygote.cpp
@@ -2285,7 +2285,9 @@ pid_t zygote::ForkCommon(JNIEnv* env, bool is_system_server,
// 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);
+ if (mallopt(M_PURGE_ALL, 0) != 1) {
+ mallopt(M_PURGE, 0);
+ }
}
pid_t pid = fork();