aboutsummaryrefslogtreecommitdiff
path: root/libc/bionic/jemalloc_wrapper.cpp
diff options
context:
space:
mode:
authorChristopher Ferris <cferris@google.com>2019-05-01 22:22:46 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-05-01 22:22:46 +0000
commit1eb6d36ba8666dace9a6f0c1db354750b331bf24 (patch)
tree62e2f8421f231c1fdd53b65ef13455a43add3bab /libc/bionic/jemalloc_wrapper.cpp
parent911fbfc2591168863a5f8a99ce15b9b9f35702b0 (diff)
parent0f710fd59346312b4e351e9d3c956bc804ff02b2 (diff)
Merge "Make purging clear the current thread cache too."
Diffstat (limited to 'libc/bionic/jemalloc_wrapper.cpp')
-rw-r--r--libc/bionic/jemalloc_wrapper.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp
index bc3a9dcdf..fd99814a6 100644
--- a/libc/bionic/jemalloc_wrapper.cpp
+++ b/libc/bionic/jemalloc_wrapper.cpp
@@ -103,6 +103,14 @@ int je_mallopt(int param, int value) {
}
return 1;
} else if (param == M_PURGE) {
+ // Only clear the current thread cache since there is no easy way to
+ // clear the caches of other threads.
+ // This must be done first so that cleared allocations get purged
+ // in the next calls.
+ if (je_mallctl("thread.tcache.flush", nullptr, nullptr, nullptr, 0) != 0) {
+ return 0;
+ }
+
unsigned narenas;
size_t sz = sizeof(unsigned);
if (je_mallctl("arenas.narenas", &narenas, &sz, nullptr, 0) != 0) {