[asterisk-dev] [Code Review] 4114: Prevent stringfields from accumulating unused memory

Corey Farrell reviewboard at asterisk.org
Mon Nov 3 12:52:56 CST 2014



> On Nov. 3, 2014, 1:12 p.m., rmudgett wrote:
> > Minor nit.
> > 
> > Does the patch still fix the reporter's memory leak?

Mostly, yes (as much as the original patch).  I'm not sure it can be fixed completely.  I tested with the reporters sip.conf.  Each peer originally allocated 2000 bytes for the stringfield's.  After 37 iterations of 'sip reload' the stringfield of all 500 peers added a new pool (allocating 8144 bytes each).  The original allocations are never freed, however the memory never grows beyond the 2nd allocation (tested to 2000 reload iterations).  At least one field in the original pool is not being blanked during reload, causing the original memory pool to never free.  The existing code causes the memory usage to increase indefinitely, so this is a major improvement.


- Corey


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/4114/#review13658
-----------------------------------------------------------


On Nov. 3, 2014, 12:55 p.m., Corey Farrell wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/4114/
> -----------------------------------------------------------
> 
> (Updated Nov. 3, 2014, 12:55 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Bugs: ASTERISK-24307
>     https://issues.asterisk.org/jira/browse/ASTERISK-24307
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> Any time a stringfield is blanked it currently prevents any currently allocated memory from being freed.  If a stringfield is repeatedly set to blank then set to a non-blank value, it causes new pools to be continuously allocated and never freed.
> 
> I'm unsure if the loop can be optimized, maybe the break can be re-added to the original location on the condition that ptr == __ast_string_field_empty?
> 
> 
> Diffs
> -----
> 
>   /branches/11/main/utils.c 427111 
>   /branches/11/include/asterisk/stringfields.h 427111 
> 
> Diff: https://reviewboard.asterisk.org/r/4114/diff/
> 
> 
> Testing
> -------
> 
> Manual test using https://github.com/elessard1/asterisk-lab/blob/master/examples/lab_stringfields_leak.c to verify that old pools are now freed.
> 
> Full testsuite against Asterisk 13.
> 
> 
> Thanks,
> 
> Corey Farrell
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20141103/5834efaa/attachment.html>


More information about the asterisk-dev mailing list