File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
components/esp32-javascript Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -402,10 +402,6 @@ static void createConsole(duk_context *ctx)
402402
403403static duk_ret_t el_suspend (duk_context * ctx )
404404{
405- // force garbage collection 2 times see duktape doc
406- // greatly increases perfomance with external memory
407- duk_gc (ctx , 0 );
408- duk_gc (ctx , 0 );
409405 // feed watchdog
410406 vTaskDelay (1 );
411407
@@ -416,6 +412,16 @@ static duk_ret_t el_suspend(duk_context *ctx)
416412 int arr_idx = duk_push_array (ctx );
417413 int arrsize = 0 ;
418414 TickType_t timeout = portMAX_DELAY ;
415+
416+ // If event queue is empty its time for a manually started garbage collection
417+ if (uxQueueMessagesWaiting (el_event_queue ) == 0 )
418+ {
419+ // force garbage collection 2 times see duktape doc
420+ // greatly increases perfomance with external memory
421+ duk_gc (ctx , 0 );
422+ duk_gc (ctx , 0 );
423+ }
424+
419425 while (xQueueReceive (el_event_queue , & events , timeout ) == pdTRUE )
420426 {
421427 timeout = 0 ; // set timeout to 0 to not wait in while loop if there are no more events available
You can’t perform that action at this time.
0 commit comments