group-icon
Arduino + Raspberry Pi Lovers
Discussion and Q&A about Arduino and Raspberry Pi projects.
186 Members
Join this group to post and comment.
Kunal Gokhe
Kunal Gokhe
Mechanical
30 Jan 2019

Get Available Free RAM

The following function will return the currently free RAM memory in bytes.

unsigned int UnusedRAM() 
{    
  unsigned int byteCounter = 0;    
  byte *byteArray;    

  while ( (byteArray = (byte*) malloc (byteCounter * sizeof(byte))) != NULL )    
  {       
      byteCounter++;        
      free(byteArray);    
  }    
  
  free(byteArray);    
  return byteCounter; 
}