From ab16dd10f148e1bd49e62ffd88d95bf6d39d5201 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Mon, 15 May 2017 16:50:29 -0700 Subject: [PATCH] Set the decay timer for all forked apps. This will cause native memory frees to be less expensive, but it will cost a bit of PSS that might hang around. Bug: 36401135 Test: Built and booted bullhead. Test: Ran jemalloc unit tests. Test: Ran bionic unit tests. Test: Ran a test that allocated and free'd a large piece of memory, Test: and verified that after changing the parameter, the PSS Test: sticks around (decay timer set to 1), the PSS is purged (decay Test: timer set to 0). Change-Id: I140b26986f3f81fddd5b9ed9c9e4f2d4977b819b --- core/jni/com_android_internal_os_Zygote.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index 6000fb56299d5..d73e7dd501408 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -519,6 +520,9 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra // The child process. gMallocLeakZygoteChild = 1; + // Set the jemalloc decay time to 1. + mallopt(M_DECAY_TIME, 1); + // Clean up any descriptors which must be closed immediately DetachDescriptors(env, fdsToClose);