Hello everyone,

We are thinking of a way to debug per module memory consumption (both private and shared). Something like a "kamctl fifo shmem module_name" to print how much memory has been alloc'ed for that module and which function had alloc'ed.

One of the solutions would be to make use of the shm_info() and pkg_info(), call them at the beginning and at the end of a function and do some subtraction at the end. Then correlate this data with a per module stats which will be printed with "kamctl stats module_name". This would be ok if one needs mem stats only for some specific modules.

Another solution would be to make use of the *_malloc stubs used when MEM_DEBUG is enabled and keep the function name and size. Buf it would be hard to count how much memory is alloc'ed by the higher module function in scenarios when the actual allocations are done in other modules (e.g. db_allocate_rows()).

Also we have in mind that one would not want to compile kamailio with MEM_DEBUG flag but still want to make use of the feature...

If you think of some other solution or have some advices for this, please comment.

Regards,
1&1 Team