Go Down

Topic: RamSize or RamLeft function ? (Read 693 times) previous topic - next topic


As we know, sometimes by doing mistakes in programming we can get ram oversize.

I don't mean abour buffer overflow or similar, but just datas the grow and goes over the available ram.

Does it exist a way of checking it ? If not can we hope one day getting a such kind of function ? Like

RamSize() would return the length of full rame of an arduino.
RameLeft() would return tha available that is not allocated.

So from it would allow us to check if the ram that is spent during a program is stable or continue to grow.

Best Regards


Does it exist a way of checking it ?

There are a couple of methods. Search for FreeMem(ory).
The art of getting good answers lies in asking good questions.


Another user did this (defining all the variables needed, serial.begin, etc)

Code: [Select]

void loop()
Serial.print("free memory = ");
Serial.print(" - memory used = ");

int availableMemory()
  int size = 8192;
  byte *buf;
  while ((buf = (byte *) malloc(--size)) == NULL);
  return size;
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Go Up