diff options
author | Luca Stefani <luca.stefani.ge1@gmail.com> | 2018-12-04 15:23:02 +0100 |
---|---|---|
committer | Luca Stefani <luca.stefani.ge1@gmail.com> | 2018-12-04 15:23:02 +0100 |
commit | 024702e117c25ca9030725f927f443f416ebbaa4 (patch) | |
tree | d6b18fecebe687441b27a06929d6d8b09a99fd96 | |
parent | 82bcdd681c7f4d9a45009535c5fc5e7c48bc7481 (diff) | |
parent | 88aacf8b28afc7ac7c4068d89041cd5af15a2906 (diff) | |
download | android_bionic-024702e117c25ca9030725f927f443f416ebbaa4.tar.gz android_bionic-024702e117c25ca9030725f927f443f416ebbaa4.tar.bz2 android_bionic-024702e117c25ca9030725f927f443f416ebbaa4.zip |
Merge tag 'android-9.0.0_r21' into lineage-16.0-android-9.0.0_r21
Android 9.0.0 release 21
* tag 'android-9.0.0_r21':
malloc: add M_PURGE mallopt flag
Change-Id: I1352461244b62d0ed02794a64f420a2bf0fbfb80
-rw-r--r-- | libc/bionic/jemalloc_wrapper.cpp | 12 | ||||
-rw-r--r-- | libc/include/malloc.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp index 19081a4c5..0e82066ee 100644 --- a/libc/bionic/jemalloc_wrapper.cpp +++ b/libc/bionic/jemalloc_wrapper.cpp @@ -79,6 +79,18 @@ int je_mallopt(int param, int value) { } } return 1; + } else if (param == M_PURGE) { + unsigned narenas; + size_t sz = sizeof(unsigned); + if (je_mallctl("arenas.narenas", &narenas, &sz, nullptr, 0) != 0) { + return 0; + } + char buffer[100]; + snprintf(buffer, sizeof(buffer), "arena.%u.purge", narenas); + if (je_mallctl(buffer, nullptr, nullptr, nullptr, 0) != 0) { + return 0; + } + return 1; } return 0; } diff --git a/libc/include/malloc.h b/libc/include/malloc.h index 3a678a94e..d850a3b83 100644 --- a/libc/include/malloc.h +++ b/libc/include/malloc.h @@ -79,6 +79,7 @@ int malloc_info(int __must_be_zero, FILE* __fp) __INTRODUCED_IN(23); /* mallopt options */ #define M_DECAY_TIME -100 +#define M_PURGE -101 int mallopt(int __option, int __value) __INTRODUCED_IN(26); /* |