[Freeswitch-dev] Do we have memory leak in eventing model?

Michael Jerris mike at jerris.com
Fri Jul 6 15:45:45 UTC 2018


Those are freed on the other end of the queue.

> On Jun 18, 2018, at 5:03 PM, Mody, Darshan (Darshan) <darshanmody at avaya.com> wrote:
> 
> We are looking into the memory leaks. We are heavily using BGAPI with lua interface.
>  
> We are currently closely looking into switch_event_queue_dispatch_event method. We don’t get why are we setting the values as NULL and not destroying the event.
>  
> static switch_status_t switch_event_queue_dispatch_event(switch_event_t **eventp)
> {
>  
>                 switch_event_t *event = *eventp;
>  
>                 if (!SYSTEM_RUNNING) {
>                                 return SWITCH_STATUS_FALSE;
>                 }
>  
>                 while (event) {
>                                 int launch = 0;
>  
>                                 switch_mutex_lock(EVENT_QUEUE_MUTEX);
>  
>                                 if (!PENDING && switch_queue_size(EVENT_DISPATCH_QUEUE) > (unsignedint)(DISPATCH_QUEUE_LEN * DISPATCH_THREAD_COUNT)) {
>                                                 if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
>                                                                 launch++;
>                                                                 PENDING++;
>                                                 }
>                                 }
>  
>                                 switch_mutex_unlock(EVENT_QUEUE_MUTEX);
>  
>                                 if (launch) {
>                                                 if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
>                                                                switch_event_launch_dispatch_threads(SOFT_MAX_DISPATCH + 1);
>                                                 }
>  
>                                                 switch_mutex_lock(EVENT_QUEUE_MUTEX);
>                                                 PENDING--;
>                                                 switch_mutex_unlock(EVENT_QUEUE_MUTEX);
>                                 }
>  
>                                 *eventp = NULL;     
>                                 switch_queue_push(EVENT_DISPATCH_QUEUE, event); ß We are pushing the event  in the queue
>                                 event = NULL;  ß we are just setting this value as NULL. Shouldn’t we destroy the event using switch_event_destroy method?
>  
>                 }
>  
>                 return SWITCH_STATUS_SUCCESS;
>  
> Help in this regard is highly appreciated.
>  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20180706/45d29d98/attachment-0001.html>


More information about the FreeSWITCH-dev mailing list