### Description pkg memory leak in register/publish scenario
#### Reproduction my presense part ``` loadmodule "presence.so" modparam("presence", "subs_db_mode", 2) # Write-Back default scheme modparam("presence", "db_update_period", 150) # 100 - default modparam("presence", "server_address", "sip:213.170.66.150:5071" ) loadmodule "presence_xml.so" modparam("presence_xml", "force_active", 1) modparam("presence_xml", "integrated_xcap_server", 1) loadmodule "pua.so" loadmodule "pua_usrloc.so" modparam("pua_usrloc", "default_domain", "siptest.ringme.ru")
```
my REGISTER processing config part ``` pua_set_publish(); if (!save("location")) sl_reply_error();
``` without pua_set_publish() everything is ok.
#### Log Messages [kamcmd corex.pkg_summary pid 10376](https://github.com/kamailio/kamailio/files/784021/corexpkg_summary.txt)
#### SIP Traffic sipp -sf register.xml -r 500 -m 100000 -s 111*222 myhost
### Additional Information
* **Kamailio Version** - output of `kamailio -v` latest git version: kamailio 5.1.0-dev1 (x86_64/linux) & kamailio 4.4.5
* **Operating System**: centos7
Was the pid 10376 printing memory allocation errors? Because the log with pkg summary doesn't show a leak, there are only few hundreds of chunks, which are allocated at startup, not at runtime.
Feb 17 21:12:00 sw5 /usr/local/dev_kamailio/sbin/kamailio[10376]: ERROR: <core> [core/mem/q_malloc.c:292]: qm_find_free(): qm_find_free(0x7f45a3ff2010, 688); Free fragment not found! Feb 17 21:12:00 sw5 /usr/local/dev_kamailio/sbin/kamailio[10376]: ERROR: <core> [core/mem/q_malloc.c:425]: qm_malloc(): qm_malloc(0x7f45a3ff2010, 688) called from core: db_res.c: db_allocate_rows(183), module: core; Free fragment not found!
If it helps, we use presence heavily and do not see this. However... we don't use the database implementation because it's never worked properly.
@snen maybe it is not a leak, but a use of large memory ... do you have sql queries with large results used in kamailio.cfg?
Btw, do you know the type of that process? It is printed by the kamctl ps command.
For the memory report, can you set mem_summary to 12 and then grab again the summary via kamcmd after letting it to run for a while?
@snen maybe it is not a leak, but a use of large memory .
it is possible of course, so it is not leak but logic issue
This process is sip worker.
1. start kamailio with "m64 -M4" (children=2) 2. check current pkg [pkg_stats_before.txt](https://github.com/kamailio/kamailio/files/787891/pkg_stats_before.txt)
3. run sipp 4. check pkg after allocation errors [pkg_stats_after.txt](https://github.com/kamailio/kamailio/files/787893/pkg_stats_after.txt)
5. summary for pid [pkg_summary_after.txt](https://github.com/kamailio/kamailio/files/787894/pkg_summary_after.txt)
Do you get error messages in the syslog containing next string?
``` ... failed sending publish for ul event ... ```
thanks! now it works correctly
Closed #1001.