Merge PQ1A.181205.006 from Pi-QPR1-Release into ToT for Pi-Platform release.\n\nBUG: 120448245

Change-Id: I41ecc8195f43208cb694877a8be2f8d86ed05312
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp
index 19081a4..0e82066 100644
--- a/libc/bionic/jemalloc_wrapper.cpp
+++ b/libc/bionic/jemalloc_wrapper.cpp
@@ -79,6 +79,18 @@
       }
     }
     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 3a678a9..d850a3b 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -79,6 +79,7 @@
 
 /* mallopt options */
 #define M_DECAY_TIME -100
+#define M_PURGE -101
 int mallopt(int __option, int __value) __INTRODUCED_IN(26);
 
 /*