- Code: Select all | TOGGLE FULL SIZE
#include <math.h>
void setup()
{
Serial.begin(9600); // set up Serial library at 9600 bps
int b;
b=availableMemory();
Serial.println(b,DEC);
}
void loop()
{
}
// this function will return the number of bytes currently free in RAM
int availableMemory()
{
int size = 1024;
byte *buf;
while ((buf = (byte *) malloc(--size)) == NULL)
;
free(buf);
return size;
}
output is
- Code: Select all | TOGGLE FULL SIZE
828
i was wondering what was used to wipe off so many bytes since there is no floating point calculation?
i have another question:let say i have a function (say it takes up 200bytes)with full of floating point calculations in it.And i need to call it quite frequently to update some other functions.will the function use up the 1k sram eventually as it was being called ?