Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Arduino - Detecting Free RAM / Free Memory
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2741
Topic starter
June 29, 2014 3:09 AM
While trying to debug a sketch, I had to test memory availability to see if I was dealing with memory leaks.
On GitHub I found this little procedure for that purpose:
int freeRam ()
{
extern int __heap_start, *__brkval;
int v;
return (int) &v - (__brkval == 0 ? (int) &__heap_start : (int) __brkval);
}
You can dump the output to your Serial monitor like so:
serial.print( freeRam() );