fix "Heap too low!" logic

"step1" (flush udp) was never activated (stupid logic error)
This commit is contained in:
Frank
2026-02-20 14:42:39 +01:00
parent 594af2baf1
commit 75c6fe1606
2 changed files with 3 additions and 1 deletions

View File

@@ -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)

View File

@@ -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);