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