[Freeswitch-dev] Memory Leak Patch

Jerry Richards jerry.richards at teotech.com
Thu May 22 02:32:53 MSD 2014


No, this is related to just an ordinary call without 100rel.  Yes, it is the memory allocated to store the "100 Trying" message, which is received after sending an INVITE.  And as I mentioned, we observed this in our phone implementation, which uses the old sofia-sip version 1.12.11 version.  I was just notifying the mailing list in case this might also be an issue for Freeswitch.  I know the Freeswitch sofia-sip has a lot changes since the 1.12.11 sofia-sip version, so maybe you guys already accounted for this memory deallocation?

-----Original Message-----
From: freeswitch-dev-bounces at lists.freeswitch.org [mailto:freeswitch-dev-bounces at lists.freeswitch.org] On Behalf Of Michael Jerris
Sent: Wednesday, May 21, 2014 2:43 PM
To: freeswitch-dev at lists.freeswitch.org
Subject: Re: [Freeswitch-dev] Memory Leak Patch

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 at 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 at lists.freeswitch.org 
> [mailto:freeswitch-dev-bounces at lists.freeswitch.org] On Behalf Of 
> Michael Jerris
> Sent: Wednesday, May 21, 2014 1:59 PM
> To: freeswitch-dev at 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 at 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 at lists.freeswitch.org
>> [mailto:freeswitch-dev-bounces at lists.freeswitch.org] On Behalf Of Ken 
>> Rice
>> Sent: Wednesday, May 21, 2014 1:37 PM
>> To: freeswitch-dev at 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 at 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 at freeswitch.org
>>> http://www.freeswitchsolutions.com
>>> 
>>>  
>>> 
>>> 
>>> Official FreeSWITCH Sites
>>> http://www.freeswitch.org
>>> http://wiki.freeswitch.org
>>> http://www.cluecon.com
>>> 
>>> FreeSWITCH-dev mailing list
>>> FreeSWITCH-dev at lists.freeswitch.org
>>> http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
>>> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-d
>>> e
>>> 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 at freeswitch.org
>> http://www.freeswitchsolutions.com
>> 
>>  
>> 
>> 
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.freeswitch.org
>> http://www.cluecon.com
>> 
>> FreeSWITCH-dev mailing list
>> FreeSWITCH-dev at 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
>> 
>> _____________________________________________________________________
>> _ ___ Professional FreeSWITCH Consulting Services:
>> consulting at freeswitch.org
>> http://www.freeswitchsolutions.com
>> 
>>  
>> 
>> 
>> Official FreeSWITCH Sites
>> http://www.freeswitch.org
>> http://wiki.freeswitch.org
>> http://www.cluecon.com
>> 
>> FreeSWITCH-dev mailing list
>> FreeSWITCH-dev at 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
> 
> 
> ______________________________________________________________________
> ___ Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
> 
>  
> 
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev at 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 at freeswitch.org
> http://www.freeswitchsolutions.com
> 
>  
> 
> 
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://wiki.freeswitch.org
> http://www.cluecon.com
> 
> FreeSWITCH-dev mailing list
> FreeSWITCH-dev at 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 at freeswitch.org
http://www.freeswitchsolutions.com

 

Official FreeSWITCH Sites
http://www.freeswitch.org
http://wiki.freeswitch.org
http://www.cluecon.com

FreeSWITCH-dev mailing list
FreeSWITCH-dev at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org



Join us at ClueCon 2013 Aug 6-8, 2013
More information about the FreeSWITCH-dev mailing list