Skip to content

Commit c665d59

Browse files
committed
revert change to free heap check, add commented code (for future use)
- free heap check in main loop should not be free contiguous heap check, it leads to random strip resets if heap runs low.
1 parent 190262f commit c665d59

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

wled00/util.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,11 @@ void *d_calloc(size_t count, size_t size) {
668668

669669
// realloc with malloc fallback, note: on ESPS8266 there is no safe way to ensure MIN_HEAP_SIZE during realloc()s, free buffer and allocate new one
670670
void *d_realloc_malloc(void *ptr, size_t size) {
671+
//void *buffer = realloc(ptr, size);
672+
//buffer = validateFreeHeap(buffer);
673+
//if (buffer) return buffer; // realloc successful
674+
//d_free(ptr); // free old buffer if realloc failed (or min heap was exceeded)
675+
//return d_malloc(size); // fallback to malloc
671676
free(ptr);
672677
return d_malloc(size);
673678
}

wled00/wled.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ void WLED::loop()
171171

172172
// reconnect WiFi to clear stale allocations if heap gets too low
173173
if (millis() - heapTime > 15000) {
174-
uint32_t heap = getContiguousFreeHeap();
174+
uint32_t heap = getFreeHeapSize();
175175
if (heap < MIN_HEAP_SIZE && lastHeap < MIN_HEAP_SIZE) {
176176
DEBUG_PRINTF_P(PSTR("Heap too low! %u\n"), heap);
177177
forceReconnect = true;

0 commit comments

Comments
 (0)