[asterisk-bugs] [Asterisk 0017081]: [patch] Memory Leak in app_queue

Asterisk Bug Tracker noreply at bugs.digium.com
Tue May 4 16:42:28 CDT 2010


A NOTE has been added to this issue. 
====================================================================== 
https://issues.asterisk.org/view.php?id=17081 
====================================================================== 
Reported By:                wliegel
Assigned To:                mmichelson
====================================================================== 
Project:                    Asterisk
Issue ID:                   17081
Category:                   Applications/app_queue
Reproducibility:            always
Severity:                   major
Priority:                   normal
Status:                     acknowledged
Target Version:             1.6.2.9
Asterisk Version:           1.6.0.26 
JIRA:                       SWP-1136 
Regression:                 No 
Reviewboard Link:            
SVN Branch (only for SVN checkouts, not tarball releases): N/A 
SVN Revision (number only!):  
Request Review:              
====================================================================== 
Date Submitted:             2010-03-23 07:12 CDT
Last Modified:              2010-05-04 16:42 CDT
====================================================================== 
Summary:                    [patch] Memory Leak in app_queue
Description: 
Hello,
on a system with lots of realtime queues I have a problem with very high
memory consumption in app_queue.
According to "memory show summary", there is a high number of allocations
in
/usr/src/asterisk-1.6.0.26/include/asterisk/strings.h:390 (>5.000.000
allocations per Day) as well as high memory consumption in app_queue.c:1449
in only a few allocations (>1GB in 778 allocations).

This issue is simply reproducible by typing "queue show" several times in
the cli and watch the allocation summary.
The more (realtime?)queues are configured the faster grows the memory
consumption after each "queue show" command.
====================================================================== 

---------------------------------------------------------------------- 
 (0121380) mmichelson (administrator) - 2010-05-04 16:42
 https://issues.asterisk.org/view.php?id=17081#c121380 
---------------------------------------------------------------------- 
I have uploaded 17081.diff to this issue.

I found that there were several calls to ast_str_create whenever I would
execute the "queue show" CLI command. This was because when realtime queues
are loaded, we start by placing all configurable values at their default
using a function called init_queue. init_queue had a bug where rather than
simply resetting the ast_str buffer that was already allocated, it would
reallocate the data, thus causing the previously allocated data to leak. As
you pointed out, if you have a lot or realtime queues, the number of
allocations can climb FAST.

You also mentioned that you were seeing allocations at line 1449 of
app_queue. The first time that I ran "queue show" I noticed the number of
allocations jump up here. This is because when you run "queue show" all
realtime queues are loaded at the time so that information can be printed
about them. However, each subsequent call to "queue show" will not result
in more allocations for realtime queues that were found previously.

Please let me know if the patch appears to fix things for you. 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2010-05-04 16:42 mmichelson     Note Added: 0121380                          
======================================================================




More information about the asterisk-bugs mailing list