FastLED 3.9.15
Loading...
Searching...
No Matches

◆ getFreeHeap()

HeapInfo fl::getFreeHeap ( )

Query available heap memory.

Returns
HeapInfo struct with free SRAM and PSRAM bytes

Platform implementations:

  • ESP32: Reports both SRAM (heap_caps_get_free_size(MALLOC_CAP_INTERNAL)) and PSRAM (heap_caps_get_free_size(MALLOC_CAP_SPIRAM)) if available
  • ESP8266: Reports SRAM only (no PSRAM support)
  • AVR: Reports available SRAM between heap and stack (no PSRAM)
  • ARM: Platform-dependent (SRAM only, no PSRAM)
  • Native/Stub: Returns {0, 0} (heap size not available in standard C++)
  • WASM: Returns {0, 0} (JavaScript heap is managed externally)

Usage:

if (heap.free_sram < 1024) {
// Low SRAM warning
}
if (heap.has_psram()) {
// PSRAM is available
}
HeapInfo getFreeHeap()
Query available heap memory.
Definition heap.cpp.hpp:67
bool has_psram() const
Check if PSRAM is available.
Definition heap.h:24
fl::size free_sram
Free SRAM in bytes (internal fast memory)
Definition heap.h:17
Heap memory information.
Definition heap.h:16

Definition at line 67 of file heap.cpp.hpp.

67 {
68 HeapInfo info;
69 info.free_sram = 0; // Not available
70 info.free_psram = 0; // Not available
71 return info;
72}
fl::size free_psram
Free PSRAM in bytes (external slower memory, 0 if not available)
Definition heap.h:18

References fl::HeapInfo::free_psram, and fl::HeapInfo::free_sram.