[asterisk-bugs] [JIRA] (ASTERISK-27121) res_pjsip_mwi: Memory leak on reload

Corey Farrell (JIRA) noreply at issues.asterisk.org
Fri Oct 20 11:17:21 CDT 2017


    [ https://issues.asterisk.org/jira/browse/ASTERISK-27121?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=239482#comment-239482 ] 

Corey Farrell commented on ASTERISK-27121:
------------------------------------------

I'm able to reproduce the issue and your patch seems to resolve it.  Do you want to post your change to gerrit [1]?  Posting to gerrit is the only way to get attention to it so others can tell us if this is the correct fix (this is slightly above my knowledge of stasis).

Note in the future please attach patches rather than posting as an inline comment.  Near the top of the page you click 'More' and then Attach files.  Even better when you have a patch that you have tested you can just post it to gerrit.  I only saw this bug because I was searching for PJSIP leak related JIRA issues.

[1] https://wiki.asterisk.org/wiki/display/AST/Code+Review

> res_pjsip_mwi: Memory leak on reload
> ------------------------------------
>
>                 Key: ASTERISK-27121
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-27121
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Resources/res_pjsip_mwi
>    Affects Versions: 13.17.0
>            Reporter: Sergej Kasumovic
>
> There seems to be a memory leak around stasis_cache which can be easily replicated with reload of res_pjsip_mwi module. I have tracked it down with REF_DEBUG config option. This is on git version of Asterisk 13 branch (cad74cdd8f). 
> My test case includes around 30 PJSIP endpoints with defined mailboxes option. 
> The number of endpoints will affect the impact of memory leak due to number of active MWI subscriptions. 
> Basically, here is the replicable scenario:
> Fetch RSS of Asterisk process
> Perform 200 reloads of res_pjsip_mwi
> Fetch RSS of Asterisk process again
> {noformat}
> ps -o rss -p $(pidof -s asterisk)
>   RSS
> 69048
> for _ in $(seq 1 200); do asterisk -rx 'module reload res_pjsip_mwi.so' >/dev/null; done
> ps -o rss -p $(pidof -s asterisk)
>   RSS
> 90460
> {noformat}
> By repeating the for loop, RSS of Asterisk process simply grows. 
> The problem seems to be around subscribe and unsubscribe message that got cached in stasis_cache. Each subscribe message is cached. However, on unsubscribe message, subscribe message is replaced with unsubscribe message and is never freed as the id of new subscription messages changes. 
> I cannot know for sure what is an ideal fix for this, but so far I was able to stop it by doing one of the following: 
> 1) Do not cache stasis_subscription_change_type() messages in stasis_cache: caching_topic_exec. It seems app_voicemail is reading these messages from cache when starting polling thread, so not sure if this is ideal solution. 
> 2) On unsubscribe message received in caching_topic_exec, make sure to remove subscription and cleanup the received message
> 3) Add another stasis_cache_clear_type() message in main/stasis.c for type stasis_subscription_change_type when doing unsubscribe
> When such fix is performed RSS does grow a bit, but then it slows down considerably. 



--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list