Summary:ASTERISK-16768: Memory leak happens when repeatedly tested
Reporter:Kwangsik (warmguy)Labels:
Date Opened:2010-10-05 02:31:04Date Closed:2014-12-23 09:40:29.000-0600
Versions:Frequency of
Environment:Attachments:( 0) pmap_400regs_tcp.log
( 1) pmap_400regs_udp.log
( 2) valgrind.txt
Description:I repeatedly registered and unregistered 200 Peers(tls-based)
Using pmap utility, I checked memory usage of asterisk process.
Memory usages increased continuously.
The following content is pmap data.

2010-10-05-15:58:45 total   148768K <-- Initialization
2010-10-05-15:58:55 total   148768K
2010-10-05-15:59:05 total   148768K
2010-10-05-15:59:15 total   148768K
2010-10-05-15:59:25 total   148768K
2010-10-05-15:59:35 total   148768K
2010-10-05-15:59:45 total   257488K
2010-10-05-15:59:55 total   338032K <-- 200 Peers is registered
2010-10-05-16:00:05 total   338032K
2010-10-05-16:00:15 total   338032K
2010-10-05-16:00:25 total   338032K
2010-10-05-16:00:35 total   338032K
2010-10-05-16:00:46 total   338032K
2010-10-05-16:00:56 total   338032K
2010-10-05-16:01:06 total   338032K
2010-10-05-16:01:16 total   338032K
2010-10-05-16:01:26 total   338032K
2010-10-05-16:01:36 total   338032K
2010-10-05-16:01:46 total   338032K
2010-10-05-16:01:56 total   338032K
2010-10-05-16:02:06 total   338032K
2010-10-05-16:02:16 total   338032K
2010-10-05-16:02:26 total   338032K
2010-10-05-16:02:36 total   328688K <-- unregistered and tls connection closed
2010-10-05-16:02:46 total   328688K
2010-10-05-16:02:56 total   328688K
2010-10-05-16:03:06 total   328688K
2010-10-05-16:03:16 total   329096K
2010-10-05-16:03:26 total   343236K <-- 200 Peers is registered
2010-10-05-16:03:36 total   343236K
2010-10-05-16:03:46 total   343236K
2010-10-05-16:03:56 total   343236K
2010-10-05-16:04:06 total   343236K
2010-10-05-16:04:16 total   343236K
2010-10-05-16:04:26 total   343236K
2010-10-05-16:04:36 total   343236K
2010-10-05-16:04:46 total   343236K
2010-10-05-16:04:56 total   343236K
2010-10-05-16:05:06 total   343236K
2010-10-05-16:05:16 total   334136K <-- unregistered and tls connection closed
2010-10-05-16:05:26 total   334136K
2010-10-05-16:05:36 total   334136K
2010-10-05-16:05:46 total   334136K
2010-10-05-16:05:56 total   334392K
2010-10-05-16:06:06 total   354200K <-- 200 Peers is registered
2010-10-05-16:06:16 total   354200K
2010-10-05-16:06:26 total   354200K
2010-10-05-16:06:36 total   354200K
2010-10-05-16:06:46 total   354200K
2010-10-05-16:06:56 total   354200K
2010-10-05-16:07:06 total   354200K

Also, when I registered 1 Peer, memory usage increased almost 1MB.

Comments:By: Leif Madsen (lmadsen) 2010-10-05 15:33:04

We're definitely going to need more information about this, but I'm not sure what.

If you're doing this in a test environment, a backtrace of the running process along with valgrind output may be useful.

By: Kwangsik (warmguy) 2010-10-06 07:42:05

In order to log using valgrind tool, I repeatedly registered and unregistered only 10 Peers. I am not familiar with valgrind. Maybe more need to study. Anyway, the following text in valgrind.txt summaries a lot of memory loss.
Help me how to test and log using valgrind.

By: Kwangsik (warmguy) 2010-10-06 07:49:30

And I will test the tcp-based registration case later.

By: Stefan Schmidt (schmidts) 2010-10-07 15:32:02

i have never used valgrind  but could you please try it again with the options which are in the last row of the valgrind output:
--leak-check=full --show-reachable=yes

thank you

By: Kwangsik (warmguy) 2010-10-07 20:19:56

To analysis this problem,
I repeatedly registered and unregistered 400 Peers(tcp-based and udp-based)
Using pmap utility, I checked memory usage of asterisk process.
In two cases(tcp,udp), memory usages did not increase. And also, these logs were attached.
In my guess, when I test tls-based registration, this problem happens.

By: Corey Farrell (coreyfarrell) 2014-11-10 00:02:54.010-0600

I know this issue is old, but I'd love to take a crack at it.  Unfortunately to do so I require output of valgrind run with parameters {{--leak-check=full --show-reachable=yes}}.  I need to know the exact version of Asterisk you used to run valgrind (so I can match line numbers from valgrind to source code).  Contents of sip.conf could be useful, so please also attach that.

Please also confirm that this is or isn't still an issue with a currently supported version of Asterisk?

By: Rusty Newton (rnewton) 2014-12-09 08:53:38.733-0600

Corey if you can't work on this without further response from the reporter then I recommend closing this out if you don't get a response in the next few weeks or can't find anyone else reproducing the same issue. Thanks for looking into this one!

By: Rusty Newton (rnewton) 2014-12-23 09:41:09.583-0600

Closing this out. If anyone can reproduce the issue on a new, supported version of Asterisk please open a new issue and provide the debug that [~coreyfarrell] has requested. Thanks!