This Arduino library prints memory usage on the Serial port.
This library provides:
- Print memory usage on the serial console
- Get stack and heap size
- Get .data and .bss sections size
Arduino IDE | Examples | Erriez Memory Usage:
void setup()
{
// Initialize serial port
Serial.begin(115200);
// Print memory usage
printMemoryUsage();
}
SRAM size: 2048 Bytes
.data size: 22 Bytes
.bss size: 170 Bytes
Stack size: 2 Bytes
Heap size: 0 Bytes
Free mem: 1854 Bytes
Get total on-chip SRAM size in Bytes:
unsigned int ramSize = getRamSize();
Get free memory size which can be allocated between stack and heap:
unsigned int freeMemSize = getFreeMemSize();
unsigned int stackSize = getStackSize();
unsigned int heapSize = getHeapSize();
unsigned int dataSize = getDataSectionSize();
unsigned int bssSize = getBssSectionSize();
Please refer to the Wiki page.