From 63e63ad156795a71a06db7f82dae3faa9738c609 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 21 May 2023 21:01:23 +0200 Subject: [PATCH] minor speedup for liveview and websockets it seems that getFreeHeap() needs some time, and blocks other tasks until completion. sendDataWS() does not need ESP.getFreeHeap() results on esp32. --- wled00/ws.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/wled00/ws.cpp b/wled00/ws.cpp index eab14d6a..8e279700 100644 --- a/wled00/ws.cpp +++ b/wled00/ws.cpp @@ -114,9 +114,9 @@ void sendDataWs(AsyncWebSocketClient * client) size_t len = measureJson(doc); DEBUG_PRINTF("JSON buffer size: %u for WS request (%u).\n", doc.memoryUsage(), len); - size_t heap1 = ESP.getFreeHeap(); - DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap()); #ifdef ESP8266 + size_t heap1 = ESP.getFreeHeap(); // WLEDMM moved into 8266 specific section + DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap()); if (len>heap1) { DEBUG_PRINTLN(F("Out of memory (WS)!")); return; @@ -140,6 +140,7 @@ void sendDataWs(AsyncWebSocketClient * client) size_t heap2 = ESP.getFreeHeap(); DEBUG_PRINT(F("heap ")); DEBUG_PRINTLN(ESP.getFreeHeap()); #else + size_t heap1 = len+16; // WLEDMM size_t heap2 = 0; // ESP32 variants do not have the same issue and will work without checking heap allocation #endif if (!buffer || heap1-heap2