Page 1 of 1
Forum

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!



Arduino - Detecting...
 
Share:
Notifications
Clear all

[Solved] Arduino - Detecting Free RAM / Free Memory

1 Posts
1 Users
0 Reactions
2,731 Views
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2741
Topic starter  

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() );

   
ReplyQuote
Share: