user25974: I use this Library to measure my free RAM on a Mega in runtime. But this Library does not work on the Due.

user10794: As mentioned by Mikael Patel in a comment, the library from Arduino-MemoryFree
 should do it. A minimal sketch that seems to work on the Due:
extern "C" char* sbrk(int incr);

int freeMemory() {
  char top;
  return &top - reinterpret_cast<char*>(sbrk(0));
}

void setup ()
{
  Serial.begin (115200);
  Serial.println ();
  Serial.print ("Free memory is: ");
  Serial.println (freeMemory ());
}  // end of setup

void loop () { }

I'm not totally convinced that this gives the correct figure. The figure returned by the library above for my Uno was too high (2297 bytes).

25974: <p>I use <a href="https://github.com/McNeight/MemoryFree" rel="nofollow">this</a> Library to measure my free RAM on a Mega in runtime. But this Library does not work on the Due.</p>
 10794: <p>As mentioned by Mikael Patel in a comment, the library from <a href="https://github.com/mpflaga/Arduino-MemoryFree" rel="nofollow">Arduino-MemoryFree
</a> should do it. A minimal sketch that seems to work on the Due:</p>

<pre class="lang-c++ prettyprint-override"><code>extern "C" char* sbrk(int incr);

int freeMemory() {
  char top;
  return &amp;top - reinterpret_cast&lt;char*&gt;(sbrk(0));
}

void setup ()
{
  Serial.begin (115200);
  Serial.println ();
  Serial.print ("Free memory is: ");
  Serial.println (freeMemory ());
}  // end of setup

void loop () { }
</code></pre>

<p>I'm not totally convinced that this gives the correct figure. The figure returned by the library above for my Uno was too high (2297 bytes).</p>
