thats strange, was this only when 100rel was turned on? I'm sure we would have noticed this if it was happening. I don't get totally what memory you are talking about, are you talking about the 100 trying we received? On May 21, 2014, at 9:25 PM, Jerry Richards <jerry.richards@teotech.com> wrote:
What we know for sure is, the memory allocated for "100 Trying" replies to outbound INVITE requests was simply not getting freed. "original->orq_timeout" seemed a convenient variable to trigger freeing this memory since it goes to zero about 25-30 seconds after the call is disconnected. Without this patch, we were losing about 3 kilobytes per outbound call.
-----Original Message----- From: freeswitch-dev-bounces@lists.freeswitch.org [mailto:freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Michael Jerris Sent: Wednesday, May 21, 2014 1:59 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Memory Leak Patch
So correct me if I'm wrong, this looks like leak on timeout on provisional reply? I don't think we have this one fixed...
On May 21, 2014, at 8:49 PM, Jerry Richards <jerry.richards@teotech.com> wrote:
Here is the patch made to the latest (today's) Freeswitch stable branch (did you fix this leak in a differently somewhere else?):
*** C:\work\SipBugs\Phone\MemoryLeak\fs_stable\nta_ORIGINAL.c 2014-02-20 18:43:27.000000000 -0700 --- C:\work\SipBugs\Phone\MemoryLeak\fs_stable\nta_PATCHED.c 2014-05-21 12:14:39.000000000 -0700 *************** *** 9166,9175 **** --- 9166,9187 ---- }
return orq; }
/** destroy msg if no timeout set on receive outgoing */ + int check_outgoing_recv_timeout(nta_outgoing_t *original, msg_t + *msg) { + SU_DEBUG_5(("nta %s: orq_timeout=%d.\n","check_outgoing_recv_timeout",original->orq_timeout)); + if(original->orq_timeout==0){ + outgoing_remove(original); + msg_destroy(msg); + return 0; + } + return original->orq_timeout; + }
/** Process a response message. */ int outgoing_recv(nta_outgoing_t *_orq, int status, msg_t *msg, sip_t *sip) *************** *** 9232,9248 **** --- 9244,9264 ---- original->orq_status = status; if (orq->orq_status < 200) orq->orq_status = status;
if (original->orq_queue == sa->sa_out.inv_calling) { outgoing_queue(sa->sa_out.inv_proceeding, original); + if(check_outgoing_recv_timeout(original,msg)==0) + return 0; } else if (original->orq_queue == sa->sa_out.inv_proceeding) { if (sa->sa_out.inv_proceeding->q_timeout) { outgoing_remove(original); outgoing_queue(sa->sa_out.inv_proceeding, original); + if(check_outgoing_recv_timeout(original,msg)==0) + return 0; } }
/* Handle 100rel */ if (sip && sip->sip_rseq) { if (outgoing_recv_reliable(orq, msg, sip) < 0) {
Here is the patch made to the latest (today's) Freeswitch master branch (did you fix this leak in a differently somewhere else?):
*** C:\work\SipBugs\Phone\MemoryLeak\fs_master\nta_ORIGINAL.c 2014-02-20 18:45:34.000000000 -0700 --- C:\work\SipBugs\Phone\MemoryLeak\fs_master\nta_PATCHED.c 2014-05-21 12:17:54.000000000 -0700 *************** *** 9307,9316 **** --- 9307,9328 ---- }
return orq; }
/** destroy msg if no timeout set on receive outgoing */ + int check_outgoing_recv_timeout(nta_outgoing_t *original, msg_t + *msg) { + SU_DEBUG_5(("nta %s: orq_timeout=%d.\n","check_outgoing_recv_timeout",original->orq_timeout)); + if(original->orq_timeout==0){ + outgoing_remove(original); + msg_destroy(msg); + return 0; + } + return original->orq_timeout; + }
/** Process a response message. */ int outgoing_recv(nta_outgoing_t *_orq, int status, msg_t *msg, sip_t *sip) *************** *** 9373,9389 **** --- 9385,9405 ---- original->orq_status = status; if (orq->orq_status < 200) orq->orq_status = status;
if (original->orq_queue == sa->sa_out.inv_calling) { outgoing_queue(sa->sa_out.inv_proceeding, original); + if(check_outgoing_recv_timeout(original,msg)==0) + return 0; } else if (original->orq_queue == sa->sa_out.inv_proceeding) { if (sa->sa_out.inv_proceeding->q_timeout) { outgoing_remove(original); outgoing_queue(sa->sa_out.inv_proceeding, original); + if(check_outgoing_recv_timeout(original,msg)==0) + return 0; } }
/* Handle 100rel */ if (sip && sip->sip_rseq) { if (outgoing_recv_reliable(orq, msg, sip) < 0) {
I realized the mailing list does not accept attachments, so I put the patches in-line here.
Jerry
-----Original Message----- From: freeswitch-dev-bounces@lists.freeswitch.org [mailto:freeswitch-dev-bounces@lists.freeswitch.org] On Behalf Of Ken Rice Sent: Wednesday, May 21, 2014 1:37 PM To: freeswitch-dev@lists.freeswitch.org Subject: Re: [Freeswitch-dev] Memory Leak Patch
You should really check the lastest version... I believe those were patched ages ago...
On 5/21/14 3:29 PM, "Jerry Richards" <jerry.richards@teotech.com> wrote:
We patched sofia-sip version 1.12.11 for memory leaks we found in sofia-sip. It's related to memory allocated for provisional replies to outbound INVITE transactions which never get freed. I suspect Freeswitch has the same issue, so I created a patch file (attached) for each of the latest (as of today) libs/sofia-sip/libsofia-sip-ua/nta/nta.c file in both the stable and master Freeswitch branches.
Do you think you can use these patches in Freeswitch? Or do you think you already fixed these memory leaks in a different way?
Best Regards, Jerry _____________________________________________________________________ _ ___ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-de v http://www.freeswitch.org
-- Ken http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org irc.freenode.net #freeswitch Twitter: @FreeSWITCH
______________________________________________________________________ ___ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
______________________________________________________________________ ___ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-dev mailing list FreeSWITCH-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org