If you think of some other solution or have some advices for this, please comment.
This has to be done as add on to the memory manager via a module, something similar to what rpc command pkg.stats does, using some callbacks, to be sure it is not slowing down the core when this feature is not wanted/enabled.

Perhaps an array with the shm and pkg counters, updated on callbacks for *malloc/*realloc/*free, still relying on module name stored in the memory chunk structure at malloc time, in order to decrease it properly at free time.
Are you referring to the #define _SRC_LOC_ _SRC_MODULE_ ": " _SRC_FILENAME_ used at the moment when kamailio is compiled with MEMDBG=1? Besides this, I could find nothing related to a module name in any memory chunk structure.

When coding the feature, it would be good to add it in between #ifdef ... #endif to be able to do performance measurments and disable it completely if has big impact. It has relevance for profiling and would be useful to have, just to be sure is not slowing down a lot.
I shall keep that in mind.


Thanks for your prompt response.

Stefan