Add a log_allocator_stats_on_exit option.
Running some types of executables, you want to get the stats at
the end of the run. Therefore, add an option to dump the allocator
stats when the program finishes.
Add new unit tests to cover this new option.
Test: All unit tests pass.
Test: Enabled the option, ran getprop and verified that the
Test: log contains the allocator stats.
Change-Id: I1c9f7d5a1fe374e8cfb6ffc8d1caa59064c5d55e
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index 6d88092..3743852 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -461,6 +461,10 @@
getpid()).c_str());
}
+ if (g_debug->config().options() & LOG_ALLOCATOR_STATS_ON_EXIT) {
+ LogAllocatorStats::Log();
+ }
+
backtrace_shutdown();
// In order to prevent any issues of threads freeing previous pointers