psram-aware malloc functions (backport of upstream #4895) (#342)

Introduces new memory allocation functions, based on wled#4895 by @DedeHai

* keep a minimum of 15KB RAM available to UI - improves stability
* S3/S2/C3 automatically use "fast RTC Ram" for small data (reduces fragmentation)
* auto-detects PSRAM (or no PSRAM) when firmware was built with -D BOARD_HAS_PSRAM
* d_malloc() and d_calloc() prefer DRAM if possible (faster), but fall back to PSRAM when free RAM gets low.
This commit is contained in:
Frank Möhle
2026-02-18 17:57:47 +01:00
committed by GitHub
parent 50bb4d2910
commit cce3c0b5d3
19 changed files with 696 additions and 191 deletions

View File

@@ -1133,6 +1133,8 @@ void serializeInfo(JsonObject root)
#if defined(ARDUINO_ARCH_ESP32)
root[F("freestack")] = uxTaskGetStackHighWaterMark(NULL); //WLEDMM
root[F("minfreeheap")] = ESP.getMinFreeHeap();
auto maxFreeBlock = getContiguousFreeHeap();
root[F("maxalloc")] = maxFreeBlock; // for upstream WLED compatibility
#endif
#if defined(ARDUINO_ARCH_ESP32)
#if defined(BOARD_HAS_PSRAM) || (ESP_IDF_VERSION_MAJOR > 3) // V4 can auto-detect PSRAM