Low memory warning

Hi all,

Using a Pro Mini due to space considerations and have just started receiving the following message during a compile. I'm using 83% of memory with 348 bytes free.

"Low memory available, stability problems may occur"

Other than the obvious, what does this mean? I'm not allocating any more memory or using up any more memory during operation. So what does the stability comment mean? I would think that as long as I'm not allocating any more memory anything greater than 0 available should be stable.

Is there something going on behind the curtain that I should know about?

Other than the obvious, what does this mean?

Your program statically allocates most of the RAM.

I’m not allocating any more memory or using up any more memory during operation.

That is hard to believe. Every function call is using dynamically allocated RAM on the stack. When function calls are nested, your program needs more memory the deeper the functions calls are nested. The memory for function calls is needed for

  • return address
  • function parameters
  • locally declared variables within functions

So what does the stability comment mean?

It means what is says.

If your functions are not nested too deep and if you are not using dynamically allocated memory like with “String objects” in any way, an amount of 250 bytes remaining memory should be enough to run your program. But it depends on the actual program, memory usage, how deep function calls are nested and which and how many parameters function calls carry with them.

jurs, thanks for the input. I guess I should have been more clear. My code is essentially complete and has been running for a number of hours without error. I don't believe that anything will change the depth of function calls the code makes so the stack shouldn't grow. I don't allocate or free memory so I hopefully don't have any leaks.

That's what I meant when I said I'm not allocating additional memory. I'll play around with a freeRam() function and print what's available while running.

If you're not creating new objects using "new", and don't use any large local variables in functions, and are not doing very deeply-nested functional calls, you should be fine. The first two are easy to evaluate, and avoid. The third would be very unusual in an Arduino program. If you have concerns, simply periodically display the amount of free RAM as the program is running. As long as it never gets close to zero, you're fine.

Regards, Ray L.

But then the next, million dollar, question is, what on earth are you doing with all the memory?

Do you use the string class? Or do you print large pieces of text to serial or something?