Tagged memory allocations
Andrei Lepikhov
lepihov at gmail.com
Sat Jun 13 11:24:28 BST 2026
Hi,
I'm using the heaptrack API to profile memory allocations in a system that is
based on memory contexts.
Heaptrack correctly traces malloc and free calls when the memory context
allocates a large memory block from the OS pool. It also works well when I trace
palloc and pfree calls that allocate memory chunks inside a pre-allocated block.
However, in the flamegraph, it seems like there is some double-counting. It
would be helpful to have an option to separate system malloc and free calls from
my internal palloc and pfree calls, and to trace memory allocations across
multiple memory contexts.
Adding a 'tag' field to the interface, where 0 could represent malloc, might
help distinguish memory-context allocations. This could also make it possible to
trace commands such as memory context reset or delete when all chunks are
returned or freed.
I'm not a regular user of memory profilers, so my question is: does this project
make sense?
--
regards, Andrei Lepikhov,
pgEdge
More information about the Heaptrack
mailing list