]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: memprof: report the delta between alloc and free on realloc()
authorWilly Tarreau <w@1wt.eu>
Fri, 22 Oct 2021 14:26:12 +0000 (16:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 22 Oct 2021 14:40:09 +0000 (16:40 +0200)
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.

src/activity.c

index b1b91aced620bb0930450c78eea2948a8759bf2c..0046f3aead7c93d1b445ed95bc5837f6fce7899a 100644 (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;