I would like to know if there is an efficient way to measure the actual memory consumption of a particular C data structure.
The goal being to make benchmarks based on how the memory usage changes after specific operations on those data structures.
I do not seek a way to count the number of objects in use; I do want to know exactly how big the memory usage of an object put under stress can get.
Is there a standard way to do that, either in C code, or from outside? (Some equivalent to the time
(1) utility would be a start).
Obviously, I could track down every single pointer and do a sum of all sizeof
s. If this is the only way, please do tell me. I wonder whether there is a simpler way. Or maybe a library to do it for me.