I've reached the limit on available SRAM memory. I need to "cut down" some variables, but I actually don't know how far I need to go with it.

Is there a way on measuring current available memory on program execution?


1 Answer 1


If you set "Show verbose output during compilation" in your IDE preferences, you'll see a message like the following in the IDE window's lower pane. The part I bolded is the amount of SRAM assigned:

Sketch uses 2,148 bytes (6%) of program storage space. Maximum is 32,256 bytes.
Global variables use 204 bytes (9%) of dynamic memory, leaving 1,844 bytes for local variables. Maximum is 2,048 bytes.

You can also include this function and print its result to get the same information on the terminal during run-time:

int freeRAM () {
  extern int __heap_start, *__brkval;
  int v;
  return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);

Not the answer you're looking for? Browse other questions tagged or ask your own question.