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.
This commit is contained in:
Willy Tarreau 2021-10-22 16:26:12 +02:00
parent a5efdff93c
commit 8cce4d79ff

View File

@ -737,9 +737,16 @@ static int cli_io_handler_show_profiling(struct appctx *appctx)
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;