malloc_debug: Implement allocation dump on exit in guarded heap.

When enabled (using heap_debug_dump_allocations_on_exit(true) or
MALLOC_DEBUG=e) this causes a dump of all remaining allocations when
libroot_debug is unloaded. It uses terminate_after to be called as
late as possible.

When combined with alloc stack traces this makes for a nice if a bit
crude leak checker. Note that a lot of allocations usually remain
even at that stage due to statically, lazyly and globally allocated
stuff from the various system libraries where it isn't necessarily
worth the overhead to free them when the program terminates anyway.
This commit is contained in:
Michael Lotz
2015-04-10 17:04:28 +02:00
parent e26a4e7b7a
commit ec0190adb0
6 changed files with 76 additions and 4 deletions
+1
View File
@@ -30,6 +30,7 @@ void *heap_debug_malloc_with_guard_page(size_t size);
status_t heap_debug_get_allocation_info(void *address, size_t *size,
thread_id *thread);
status_t heap_debug_dump_allocations_on_exit(bool enabled);
status_t heap_debug_set_stack_trace_depth(size_t stackTraceDepth);
#ifdef __cplusplus