I need to measure the amount of RAM used up by my code on Due. Can anybody tell me how to do it.
Thanks in advance.
Have you got an answer yet.
There are ways to to do it with other Arduinos. Is it different than with DUE.
There are libraries/functions for the AVRs but I don't know if they have been ported to the SAM.
A quick and dirty way is to malloc() a single byte and get it's address, subtract that value from the max RAM address then subtract a fudge factor for the stack.
On LPCs you can get the SP as well and that's probably a option on the SAM, but you could also call a dummy function and get the address of a local variable to get an approx stack value. Or for that matter get the address of a local var in loop().
Rob
This seems to provide a good number on a Mega
void setup() {
byte stack;
long heap = (long)malloc(1);
Serial.println ((long)&stack );
Serial.println (heap);
Serial.println ((long)&stack - heap);
}
No reason to believe it would not work on the Due.
Rob