Hello,
(cross-posting as it is relevant to user community as well).
I just pushed a bunch of patches to master branch that will allow selecting the memory manger at kamailio startup, no longer needed to re-compile sources. There are two new command line parameters:
* -x name: select the memory manager for shm * -X name: select the memory manager for pkg * if -x is provided but -X is not provided, then pkg uses same memory manager as shm * name can be: * fm - fast malloc (f_malloc) * qm - quick malloc (q_malloc) * default memory manager is fm (what was default so far)
Both f_malloc and q_malloc are now compiled, selecting one or the other being possible. Other managers expected to be added in the list soon, especially TLSF, added not that long ago by Camille Oudot. Maybe reviving Doug Lea malloc (existing in dl_malloc.c) worth a try now that can be easily used.
The debugging mode for each memory manager is controlled by DB_SR_MEMORY define via Makefile.defs -- right now it is enabled. All enabled memory mangers must be compiled either with or without DB_SR_MEMORY (it won't work to have one memory manger with DB_SR_MEMORY and another one without).
Using system malloc for private (pkg) memory is possible by removing the define of PKG_MALLOC from Makefile.defs (same as it was before). This is a mode suitable for troubleshooting using external tools such as valgrind, because it does inline replacement of pkg_malloc() with malloc(), so those tools can track the place of allocation. I plan to add a system malloc custom manager, to allow selecting it with -X (system malloc won't work for shm management, because it is only for private memory).
There is no performance impact at runtime, it is only the startup procedure that replaces the pointers to memory management functions.
Hopefully with the new mechanism will be able to track easier memory issues -- e.g., qm malloc is better for troubleshooting, using it no longer requires recompilation, just starting kamailio with -x qm.
Feedback, especially testing, will be very appreciated!
Cheers, Daniel