[asterisk-dev] [Code Review] MALLOC_HOLD for debugging memory

Tilghman Lesher tlesher at digium.com
Tue Jul 14 11:34:18 CDT 2009



> On 2009-07-13 21:18:46, Russell Bryant wrote:
> > Here is a thought that came to mind with this.
> > 
> > There are a number of situations in Asterisk where holding on to memory allocations for an extended period of time like this is concerning.  For example, for IAX2 calls, every single incoming audio frame requires a malloc() and a free().  Since, these malloc() / free() calls happen in separate threads, the frame cache does not apply to this scenario.
> > 
> > A rough calculation ... an IAX2 call using ulaw at 64 kbps, for two minutes ... 64 kb/s * 120 s = 7680 kb / 2 minutes = 960 kB / 2 minutes.  So, let's fudge it a bit and tack on the overhead of the ast_frame structure and call it 1 MB for 1 channel over 2 minutes.  It's not just a MB, but it's 1 MB broken up into 6000 allocations (50 frames per second * 120 seconds).  So now, let's say we have 50 IAX2 calls.  It's taking up roughly 50 MB of memory.  However, that 50 MB is in 300,000 allocations.  The performance of the code in astmm.c is going to cripple long before it gets to here, I bet.
> > 
> > The testing done section says "extensive testing with an idle system".  This sounds like an oxymoron to me.  :-)  I would be interested to see how this performs under load, and especially types of load that are going to produce _lots_ of allocations.  I suspect that we will find that a more efficient storage method will be required.

When I said idle system, I meant a system that has had, at max, 2 concurrent IAX sessions.  I do agree, though, that the number of allocations might make this a bit slow, so I'll look into techniques for fixing that.


- Tilghman


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


On 2009-07-13 17:04:05, Tilghman Lesher wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/309/
> -----------------------------------------------------------
> 
> (Updated 2009-07-13 17:04:05)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> MALLOC_HOLD is an optional compile-time definition used to detect memory corruption.  It does this in a similar way to valgrind, although it does not slow down Asterisk appreciably (although the memory will grow somewhat larger than normal).
> 
> 
> Diffs
> -----
> 
>   /branches/1.4/build_tools/cflags.xml 206144 
>   /branches/1.4/main/astmm.c 206144 
> 
> Diff: https://reviewboard.asterisk.org/r/309/diff
> 
> 
> Testing
> -------
> 
> Extensive testing with an idle system.
> 
> 
> Thanks,
> 
> Tilghman
> 
>




More information about the asterisk-dev mailing list