From 75c6fe1606e4aae3f534c4c213742c5403839d6e Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 20 Feb 2026 14:42:39 +0100 Subject: [PATCH] fix "Heap too low!" logic "step1" (flush udp) was never activated (stupid logic error) --- wled00/const.h | 2 ++ wled00/wled.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/wled00/const.h b/wled00/const.h index 1953d5ee..a422dfdd 100644 --- a/wled00/const.h +++ b/wled00/const.h @@ -536,6 +536,8 @@ #define MIN_HEAP_SIZE (15*1024) // WLED allocation functions (util.cpp) try to keep this much contiguous heap free for other tasks #endif #endif +#define MIN_HEAP_CRIT_SIZE (unsigned(MIN_HEAP_SIZE - (MIN_HEAP_SIZE/8))) // allow 12% margin before for "critical low" + // threshold for PSRAM use: if heap is running low, requests to allocate_buffer(prefer DRAM) above PSRAM_THRESHOLD may be put in PSRAM // if heap is depleted, PSRAM will be used regardless of threshold #if defined(CONFIG_IDF_TARGET_ESP32S3) diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 64398dac..266bcbd9 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -1363,7 +1363,7 @@ void WLED::handleConnection() //uint32_t heap = heap_caps_get_largest_free_block(0x1800); // WLEDMM: This is a better metric for free heap. uint32_t heap = getContiguousFreeHeap(); // WLEDMM: This is a better metric for free heap. #endif - if (heap < MIN_HEAP_SIZE && lastHeap < MIN_HEAP_SIZE) { + if (heap < MIN_HEAP_CRIT_SIZE && lastHeap < MIN_HEAP_SIZE) { // WLEDMM allow 12% extra margin before "critical" if (retryCount < 5) { // WLEDMM avoid repeated disconnects USER_PRINT(F("Heap too low! (step 2, force reconnect): ")); USER_PRINTLN(heap);