MINOR: memprof: report the delta between alloc and free on realloc()
realloc() calls are painful to analyse because they have two non-zero
columns and trying to spot a leaking one requires a bit of scripting.
Let's simply append the delta at the end of the line when alloc and
free are non-nul.
It would be useful to backport this to 2.4 to help with bug reports.
diff --git a/src/activity.c b/src/activity.c
index b1b91ac..0046f3a 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -737,9 +737,16 @@
else
chunk_appendf(&trash, "[other]");
- chunk_appendf(&trash," %s(%lld)\n", memprof_methods[entry->method],
+ chunk_appendf(&trash," %s(%lld)", memprof_methods[entry->method],
(long long)(entry->alloc_tot - entry->free_tot) / (long long)(entry->alloc_calls + entry->free_calls));
+ if (entry->alloc_tot && entry->free_tot) {
+ /* that's a realloc, show the total diff to help spot leaks */
+ chunk_appendf(&trash," [delta=%lld]", (long long)(entry->alloc_tot - entry->free_tot));
+ }
+
+ chunk_appendf(&trash, "\n");
+
if (ci_putchk(si_ic(si), &trash) == -1) {
si_rx_room_blk(si);
return 0;