[SR-Users] pkg.stats problem

Hugh Waite hugh.waite at crocodile-rcs.com
Thu Sep 26 13:02:28 CEST 2013

I fixed some memory leaks in master on 4th July.

The main leak I was investigating was the tcp connection structures used 
by the websocket module. When the connection is used, the ref count is 
increased, and should be decreased when each packet/transaction etc has 
completed. Each connection includes a tcp buffer, so leaking these can 
use up the memory very fast.
I put some extra info into the kamcmd core.tcp_list command to display 
the refcount. If during use, the refcount is always increasing, then 
this structure will not be freed when the connection closes, but it will 
disappear from the list.

I went through and checked that all tcpconn_get and tcpconn_put calls 
were done, this improved the situation a lot, but I don't think I fully 
fixed it - we were still getting some increasing refcounts. I sent a 
message to the dev list 
(http://lists.sip-router.org/pipermail/sr-dev/2013-July/020624.html) to 
check if my use of tcpconn_put/get was correct, but no-one agreed or 
disagreed. Maybe it just needs some extra pairs of eyes on the code.


On 26/09/2013 10:18, Daniel-Constantin Mierla wrote:
> Hello,
> the output of top is not relevant, because kamailio uses an internal 
> memory manager. If system memory is increasing, then it is likely to 
> be from an external library.
> I saw there was work on websocket, not being the developer I don't 
> know if it something to be backported. Maybe Peter or Hugh can jump 
> here with clarifications.
> Cheers,
> Daniel
> On 9/25/13 12:40 PM, Vitaliy Aleksandrov wrote:
>> I switched to the latest master branch and it seems it works better, 
>> but unfortunately I can't understand how much PKG memory kamailio 
>> really uses to know it still has problems with PKG.
>> For instance "kamcmd pkg.stats" always shows that tcp_main process 
>> has free: 32627984 (started with -M 32), while real_used: 22560048 
>> and RES in top output for the same process is 8904.
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

Hugh Waite
Principal Design Engineer
Crocodile RCS Ltd.

More information about the sr-users mailing list