It is not clear what type of memory leaks? Is it the on managed by kamailio in pkg or shm? Or is the system memory? Because in the shell script you use system's `free`.
To watch kamailio's shm memory do:
``` kamctl stats shmem ```
For pkg:
``` kamctl rpc pkg.stats ```
If it is system memory, then the logs of kamailio related to qm_status are irrelevant.
So once it is clarified what memory type is leaking, then we can provide next steps to analyze the issue.