]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MINOR: memprof: add one pointer size to the size of allocations
authorWilly Tarreau <w@1wt.eu>
Fri, 22 Oct 2021 14:33:53 +0000 (16:33 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 22 Oct 2021 14:40:09 +0000 (16:40 +0200)
commit1de51eb7279fb4257bdb3816c5e9a7990b7ae211
tree0ade3e5921458e4af3c0daf7db5d473f2096ca36
parent8cce4d79ff8e448b033aca9b4b09db3b7acf7928
MINOR: memprof: add one pointer size to the size of allocations

The current model causes an issue when trying to spot memory leaks,
because malloc(0) or realloc(0) do not count as allocations since we only
account for the application-usable size. This is the problem that made
issue #1406 not to appear as a leak.

What we're doing now is to account for one extra pointer (the one that
memory allocators usually place before the returned area), so that a
malloc(0) will properly account for 4 or 8 bytes. We don't need something
exact, we just need something non-zero so that a realloc(X) followed by a
realloc(0) without a free() gives a small non-zero result.

It was verified that the results are stable including in the presence
of lots of malloc/realloc/free as happens when stressing Lua.

It would make sense to backport this to 2.4 as it helps in bug reports.
src/activity.c