Purge memory.

Some operations wind up allocating then freeing a significant
amount of memory. So after those operations, do a purge so that
the RSS of the process is not artificially inflated.

Bug: 262321164

Test: Ran unit tests.
Test: Verified after this change, the RSS does not go up after running
Test: am dumpheap -n <PID>.
Change-Id: I08477f8ce12c06fd2a068f536a81f4a577d619e2
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 4bc5649..7b0f599 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -494,6 +494,9 @@
 
 void debug_free_malloc_leak_info(uint8_t* info) {
   g_dispatch->free(info);
+  // Purge the memory that was freed since a significant amount of
+  // memory could have been allocated and freed.
+  g_dispatch->mallopt(M_PURGE, 0);
 }
 
 size_t debug_malloc_usable_size(void* pointer) {
@@ -1117,6 +1120,10 @@
     dprintf(fd, "%s", content.c_str());
   }
   dprintf(fd, "END\n");
+
+  // Purge the memory that was allocated and freed during this operation
+  // since it can be large enough to expand the RSS significantly.
+  g_dispatch->mallopt(M_PURGE, 0);
 }
 
 bool debug_write_malloc_leak_info(FILE* fp) {