diff options
author | Christopher Ferris <cferris@google.com> | 2019-05-01 17:09:34 -0700 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2019-05-01 17:09:34 -0700 |
commit | a5b6f60083ef4571818dbfda6da720aa19775ffa (patch) | |
tree | bbb6cab3c845af517dd1807a75b0b5c629b8649f | |
parent | 8dc7da51b537e301bf6ee05e7fb56e97df23a7d1 (diff) | |
parent | 58567dcd7837e7fe81f3235c32807185cb20a99d (diff) | |
download | android_bionic-a5b6f60083ef4571818dbfda6da720aa19775ffa.tar.gz android_bionic-a5b6f60083ef4571818dbfda6da720aa19775ffa.tar.bz2 android_bionic-a5b6f60083ef4571818dbfda6da720aa19775ffa.zip |
Make purging clear the current thread cache too.
am: 58567dcd78
Change-Id: Ifd5dbf7e92788873827814445388e99ab6503e7b
-rw-r--r-- | libc/bionic/jemalloc_wrapper.cpp | 8 |
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) { |