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

Mody, Darshan (Darshan) darshanmody at avaya.com
Mon Jun 18 21:03:55 UTC 2018


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) > (unsigned int)(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.

Thanks
Darshan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freeswitch.org/pipermail/freeswitch-dev/attachments/20180618/7bf26962/attachment-0001.html>


More information about the FreeSWITCH-dev mailing list