[asterisk-dev] pjsip and ast_sip_add_header - memory management?
Michael Maier
m1278468 at mailbox.org
Sat Aug 31 06:30:57 CDT 2019
Am 31.08.19 um 12:33 schrieb Joshua C. Colp:
> On Sat, Aug 31, 2019, at 7:04 AM, Michael Maier wrote:
>> Hello!
>>
>> If there are headers added to a request using ast_sip_add_header: who is responsible for the memory management of the added headers? At the moment I suspect, that
>> there is a memory leak using ast_sip_add_header because I can see slightly but constantly more growing memory usage (see mediasec patches [1] e.g.), which I didn't saw
>> before (asterisk doesn't that heavily rely on ast_sip_add_header - but REGISTER and OPTIONS requests are sent regularly and very often).
>
> PJSIP itself is technically. It uses a pool approach where many structures allocate a pool and then the contents of the structure are allocated from that pool, so you
> can't actually free individual aspects without freeing everything about the structure by freeing the pool. This is what happens for ast_sip_add_header - it's allocated
> from the pool for the outgoing message, just like other parts of the message itself.
>
> Is ast_sip_add_header being called multiple times for the same tdata? That could cause the memory usage to increase, since the pool would just grow.
Yes. Up to 3 times for a register request (at the moment with a new patch). I can see *growing memory usage each hour* by about 2000 bytes or more (depends on the amount of
REGISTERS each hour) during normal operation.
Background: because of an outage / problem of the ISP this week, I got two times massive memory usage of asterisk until oom-killer reaped asterisk. During this period,
there have been a lot of REGISTERS (for 3 numbers) going out each minute which where not answered respectively they sent 0 bytes SSL packages
(-> pjproject: SSL 6 [SSL_ERROR_ZERO_RETURN] (Read) ret: 0 len: 32000)
Thanks
Michael
More information about the asterisk-dev
mailing list