Memory issue / Determine remaining RAM

Ok - For a memory free test try the following code. Note that the slab allocator only grabs chunks when needed and that the "delete" does not seem to affect the free amount. I assume that with a more exhaustive test that the delete will be shown to work. Also note that YOU CANNOT MIX new/malloc and free/delete functionality.

--------

extern "C" char *sbrk(int i);

int FreeRam () {
char stack_dummy = 0;
return &stack_dummy - sbrk(0);
}

void setup() {
while( !SerialUSB ) ;
SerialUSB.begin(9600);

}

int n = 0;
char *buffer;

void loop() {
n++;
buffer = new char[n];
SerialUSB.print( "Free Ram :" + String(FreeRam(), DEC) + " After new of:" + String(n, DEC) + " bytes");
delay(50);
delete[] buffer;
SerialUSB.println( " Free Ram after deletes:" + String(FreeRam(), DEC) );
if( n > 10000 ) n = 0;
}