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?
Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. It only takes a minute to sign up.
Sign up to join this communityI'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?
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);
}