Skip to content

Commit 36eb520

Browse files
committed
reduce RAM needs for -S2, user message on heap emergency actions
1 parent c8cee6c commit 36eb520

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

wled00/const.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@
448448
#if defined(ARDUINO_ARCH_ESP32C3)
449449
#define JSON_BUFFER_SIZE 44000 // WLEDMM - max 44KB on -C3 with PSRAM (chip has 400kb RAM)
450450
#else
451-
#define JSON_BUFFER_SIZE 32000 // WLEDMM - max 32KB on -S2 with PSRAM (chip has 320kb RAM)
451+
#define JSON_BUFFER_SIZE 28000 // WLEDMM - max 28KB on -S2 with PSRAM (chip has 320kb RAM)
452452
#endif
453453
#else
454454
#define JSON_BUFFER_SIZE 54000 // WLEDMM (was 60000) slightly reduced to avoid build error "region dram0_0_seg overflowed"

wled00/wled.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,16 +1180,19 @@ void WLED::handleConnection()
11801180
#ifdef ARDUINO_ARCH_ESP32
11811181
// reconnect WiFi to clear stale allocations if heap gets too low
11821182
if (now - heapTime > 5000) { // WLEDMM: updated with better logic for small heap available by block, not total.
1183-
// uint32_t heap = ESP.getFreeHeap();
1183+
#if defined(ARDUINO_ARCH_ESP32S2)
1184+
uint32_t heap = ESP.getFreeHeap(); // WLEDMM works better on -S2
1185+
#else
11841186
uint32_t heap = heap_caps_get_largest_free_block(0x1800); // WLEDMM: This is a better metric for free heap.
1187+
#endif
11851188
if (heap < MIN_HEAP_SIZE && lastHeap < MIN_HEAP_SIZE) {
1186-
DEBUG_PRINT(F("Heap too low! (step 2, force reconnect): "));
1187-
DEBUG_PRINTLN(heap);
1189+
USER_PRINT(F("Heap too low! (step 2, force reconnect): "));
1190+
USER_PRINTLN(heap);
11881191
forceReconnect = true;
11891192
strip.purgeSegments(true); // remove all but one segments from memory
11901193
} else if (heap < MIN_HEAP_SIZE) {
1191-
DEBUG_PRINT(F("Heap too low! (step 1, flush unread UDP): "));
1192-
DEBUG_PRINTLN(heap);
1194+
USER_PRINT(F("Heap too low! (step 1, flush unread UDP): "));
1195+
USER_PRINTLN(heap);
11931196
strip.purgeSegments();
11941197
notifierUdp.flush();
11951198
rgbUdp.flush();

0 commit comments

Comments
 (0)