[asterisk-dev] [Code Review] A whole mess of ref counting cleanups

Matt Jordan reviewboard at asterisk.org
Mon Oct 1 15:31:02 CDT 2012


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

(Updated Oct. 1, 2012, 3:31 p.m.)


Review request for Asterisk Developers, Mark Michelson, rmudgett, and jcolp.


Changes
-------

Addressed Mark's findings.


Summary
-------

While hunting for a channel ref leak, I found that after running the refcounter utility, there were a whole host of ao2 object ref leaks.  Wondering if that was just my test causing that, I started Asterisk and immediately stopped it.

Nope, lots of ref leaks still.

This patch cleans up a fair number of them - so that at least with my admittedly limited configuration (which had a number of modules excluded), there were no longer any ao2 ref leaks on Asterisk shutdown.  Most of these are simply Asterisk not properly cleaning up after itself on shutdown; however, a few could arguably result in slow growing memory leaks, particularly in systems that used frequent reloads.

Still haven't found the channel ref leak, but this does remove a lot of error messages.

Note that while this patch is for trunk, a version should be applied to 1.8, 10, and 11 as well.

For Richard:

I noticed that some of the internally allocated nodes in astobj2 would not be represented in a REF_DEBUG log, as they never used a 'debug' version of ao2_alloc or ao2_ref.  Unfortunately, a few code paths resulted in those same nodes showing up in the REF_DEBUG log, leading to warnings that nodes were appearing that were never allocated.  This patch manages to get all of the nodes represented in a REF_DEBUG log; however, I imagine that for the red/black tree work, this is going to be compounded.  If you have another approach you'd like to take other than what I have here, let me know.


Diffs (updated)
-----

  /trunk/include/asterisk/astobj2.h 374095 
  /trunk/channels/chan_agent.c 374095 
  /trunk/main/cel.c 374095 
  /trunk/main/channel.c 374095 
  /trunk/main/config_options.c 374095 
  /trunk/main/data.c 374095 
  /trunk/main/asterisk.c 374095 
  /trunk/main/astobj2.c 374095 
  /trunk/main/ccss.c 374095 
  /trunk/main/db.c 374095 
  /trunk/main/event.c 374095 
  /trunk/main/features.c 374095 
  /trunk/main/format.c 374095 
  /trunk/main/format_pref.c 374095 
  /trunk/main/indications.c 374095 
  /trunk/main/manager.c 374095 
  /trunk/main/message.c 374095 
  /trunk/main/named_acl.c 374095 
  /trunk/main/pbx.c 374095 
  /trunk/main/taskprocessor.c 374095 
  /trunk/main/udptl.c 374095 
  /trunk/main/xmldoc.c 374095 
  /trunk/res/res_musiconhold.c 374095 
  /trunk/res/res_xmpp.c 374095 

Diff: https://reviewboard.asterisk.org/r/2137/diff


Testing
-------

A whole lot of loading/unloading, changing configuration, and generally peeking through REF_DEBUG logs.


Thanks,

Matt

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20121001/0c9bbf10/attachment-0001.htm>


More information about the asterisk-dev mailing list