RAM Issues Resolved

FYI,

I have been programming my Arduino Mega 2560 for some time now. My largest program is over 100 kb. The biggest problem that I had was memory availability. Due to the many functions used and the many different sequence of events, I found it extremely difficult to determine if I would run out of memory at some point. My program was designed to run continuously for very long periods of time.

The only way I found to feel comfortable that I would not run out of memory was the following:

  • After the program loads, I determine the start and end of the initially available RAM.

  • I then fill this area of memory with a known pattern of data (Ex. QWERTYQWERTYQWERTY...)

  • When a function begins or ends, I find the beginning and end of my pattern.

  • The number of bytes containing my pattern, gives me the minimum amount of memory that was available.

  • I log this amount to a file on the SD card and can also view this by sending a request to the Arduino.

I hope this helps someone out there as it did for me.

Nick Amendola

nickamen:

  • The number of bytes containing my pattern, gives me the minimum amount of memory that was available.

  • I log this amount to a file on the SD card and can also view this by sending a request to the Arduino.

I hope this helps someone out there as it did for me.

Nick Amendola

Check out this little library: Arduino Playground - HomePage

May help you.

I tried using various libraries but none would tell me, after the fact, the minimum memory that I had available during execution. The library functions I used only told me how much memory I had at the time of the request.

nickamen:
I tried using various libraries but none would tell me, after the fact, the minimum memory that I had available during execution. The library functions I used only told me how much memory I had at the time of the request.

Nothing stopping you from calling it over and over again... or putting it inside your main loop and recording the values somewhere.