This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
tutorials:troubleshooting:memory [2015/01/16 17:37] miconda [Using GDB] |
tutorials:troubleshooting:memory [2015/09/04 00:47] miconda [Memory Manager Debugging] |
||
---|---|---|---|
Line 63: | Line 63: | ||
* if the number of subscribers, | * if the number of subscribers, | ||
- | ===== Troubleshooting ===== | ||
===== Memory Manager Debugging ===== | ===== Memory Manager Debugging ===== | ||
Line 114: | Line 113: | ||
* for SHM memory: | * for SHM memory: | ||
< | < | ||
- | kamcmd cfg.set_now_int core mem_dump_shm | + | kamcmd cfg.set_now_int core mem_dump_shm |
</ | </ | ||
Line 136: | Line 135: | ||
For PKG is similar format, just SHM replaced with PKG in messages. | For PKG is similar format, just SHM replaced with PKG in messages. | ||
+ | To generate summary report, do: | ||
+ | |||
+ | < | ||
+ | # first set memlog lower than debug | ||
+ | kamcmd cfg.set_now_int core memlog 1 | ||
+ | |||
+ | kamcmd corex.shm_summary | ||
+ | </ | ||
+ | |||
+ | The log for f_malloc with debug enabled should look like: | ||
+ | |||
+ | < | ||
+ | 20(4082) NOTICE: fm_status: summarizing all alloc' | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | 20(4082) NOTICE: fm_status: | ||
+ | |||
+ | </ | ||
===== Using GDB ===== | ===== Using GDB ===== | ||
Line 190: | Line 213: | ||
gdb --batch --command=/ | gdb --batch --command=/ | ||
</ | </ | ||
+ | |||
+ | ===== PKG With System Malloc ===== | ||
+ | |||
+ | Kamailio can be compiled to use system malloc and free for PKG needs. You have to remove the PKG_MALLOC define from Makefile.defs and can add DBG_SYS_MALLOC to get more verbosity with memory operations in debug mode. | ||
+ | |||
+ | Next is a diff showing the changes in Makefile.defs, | ||
+ | |||
+ | <code c> | ||
+ | diff --git a/ | ||
+ | index 3890668..12ca37a 100644 | ||
+ | --- a/ | ||
+ | +++ b/ | ||
+ | @@ -621,7 +621,7 @@ C_DEFS= $(extra_defs) \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | - -DPKG_MALLOC \ | ||
+ | + -DDBG_SYS_MALLOC \ | ||
+ | | ||
+ | | ||
+ | | ||
+ | </ | ||
+ | |||
+ | After updating Makefile.defs recompile and reinstall. | ||
+ | |||
+ | Other tools available out there (e.g., valgrind) can be then used to track the PKG memory operations done by Kamailio. | ||
===== OS Memory Reports ===== | ===== OS Memory Reports ===== |