sram-free

wayland/memory-free/sram-free

Measure free Static Random Access Memory (SRAM).
sram-free
@/sram-free
Measure free Static Random Access Memory (SRAM).
UPDpulse
Update. Trigger measurement of free SRAM.
sram-free
UPD
SRAM
SRAMnumber
Available SRAM in bytes.
To use the node in your project you should have the wayland/memory-free library installed. Use the “File → Add Library” menu item in XOD IDE if you don’t have it yet. See Using libraries for more info.

C++ implementation

// Source: https://github.com/mpflaga/Arduino-MemoryFree
#ifdef __arm__
// should use uinstd.h to define sbrk but Due causes a conflict
extern "C" char* sbrk(int incr);
#else  // __ARM__
extern char *__brkval;
#endif  // __arm__

int freeMemory() {
  char top;
#ifdef __arm__
  return &top - reinterpret_cast<char*>(sbrk(0));
#elif defined(CORE_TEENSY) || (ARDUINO > 103 && ARDUINO != 151)
  return &top - __brkval;
#else  // __arm__
  return __brkval ? &top - __brkval : &top - __malloc_heap_start;
#endif  // __arm__
}


node {

    void evaluate(Context ctx) {
        if (isInputDirty<input_UPD>(ctx)) {
            emitValue<output_SRAM>(ctx, freeMemory());
        }
    }
}