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
This commit is contained in:
Christopher Ferris
2023-02-28 12:51:03 -08:00
parent ae41acbe90
commit 571aa6fb49

View File

@@ -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();