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.
(cherry picked from commit 8cce4d79ff8e448b033aca9b4b09db3b7acf7928)
Signed-off-by: Willy Tarreau <w@1wt.eu>
diff --git a/src/activity.c b/src/activity.c
index 6ed6fc5..4a7def1 100644
--- a/src/activity.c
+++ b/src/activity.c
@@ -675,9 +675,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;