[asterisk-bugs] [Asterisk 0013409]: [patch] Huge memory leak because memory of channel cdr struct is never returned

Asterisk Bug Tracker noreply at bugs.digium.com
Tue Sep 9 07:41:37 CDT 2008


A NOTE has been added to this issue. 
====================================================================== 
http://bugs.digium.com/view.php?id=13409 
====================================================================== 
Reported By:                tomaso
Assigned To:                murf
====================================================================== 
Project:                    Asterisk
Issue ID:                   13409
Category:                   Core/Channels
Reproducibility:            always
Severity:                   block
Priority:                   normal
Status:                     feedback
Asterisk Version:           SVN 
SVN Branch (only for SVN checkouts, not tarball releases): 1.6.0 
SVN Revision (number only!): 137818 
Disclaimer on File?:        N/A 
Request Review:              
====================================================================== 
Date Submitted:             2008-09-01 09:48 CDT
Last Modified:              2008-09-09 07:41 CDT
====================================================================== 
Summary:                    [patch] Huge memory leak because memory of channel
cdr struct is never returned
Description: 
After two days of stress testing by making lots of calls across sip and
dahdi channels the asterisk process memory reached dizzy values: VSZ=3,2GB,
RSS=1,6GB before asterisk stucked completely (even the RAM of our server
(2GB) is finite ;-) ).

Actually this problem is not a question of load, but appears for each
single call.

Using valgrind the reason for that was quickly found: The memory of the
channel cdr struct (chan->cdr) is never returned, not for sip, not for
dahdi channels, when a channel is cleared.

Reproduce:
a.f.a.p. default configuration (modules.conf, etc.)
Make lots of calls and see ps's VSZ and RSS values.

Interested in a patch ? Or is someone revise this anyway?

======================================================================
Relationships       ID      Summary
----------------------------------------------------------------------
related to          0013235 Memory leak in Asterisk 1.4 and Trunk
related to          0013444 After update from 140415 to 141991 get ...
====================================================================== 

---------------------------------------------------------------------- 
 (0092234) tomaso (reporter) - 2008-09-09 07:41
 http://bugs.digium.com/view.php?id=13409#c92234 
---------------------------------------------------------------------- 
Hi folks, I checked out the SVN revs 141566 and 141567. In the attached
files you can see the channels which are in Rx: BYE state (during stress
test). In rev 141567 they are less because the channels seem to be cleared
earlier. But even in svn 141566 all Rx: BYE state channels are cleared
earlier or later. So this was never a real problem for us.

The memory usage of asterisk in svn 141567 is almost the same (here about
13MB) as in svn 141566, i.e. no increasing memory leak during the stress
test. That's o.k. for both versions.

Regarding the cdr issues / segmentation fault:
Yes the code in ast_bridge_call() is quite ugly! So it's not a surprise
that asterisk stuck. The way the cdr's are handled in some functions is not
acceptable. 
And someone should take a look on the ast_channel_unlock() and
ast_channel_lock() calls. There are leaks which make it easy/possible that
segmentation faults like the one above occur.

@murf: So it seems there are still a lot of ants which can even frighten
the big elephant! ;-) 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2008-09-09 07:41 tomaso         Note Added: 0092234                          
======================================================================




More information about the asterisk-bugs mailing list