Hello!
I'm using an Arduino Mega 2560. It has 8KB of SRAM.
How much SRAM can I use? It's recommended to not to use all the available SRAM? I have to leave 10%-20%.. of SRAM free?
TY
Hello!
I'm using an Arduino Mega 2560. It has 8KB of SRAM.
How much SRAM can I use? It's recommended to not to use all the available SRAM? I have to leave 10%-20%.. of SRAM free?
TY
It all rather depends on how you use the RAM.
That is a difficult question to answer. The IDE reports SRAM used for global variables and literals that the compiler can see at compile time. It cannot know how much SRAM is used in run time for local variables. So, if you have 60% available and declare a 1000 byte local buffer array you can run into trouble. Or if you have 90% available and no local variables you could be OK.
My conclusion is that you can't put a number on how much you need. It would be a case by case thing.
Things like the using the smallest data types , the F macro, PROGMEM and using const will help to maximize SRAM.
Well, do you know how every library is using RAM?
Is there any function that tells the actual amount of remaining RAM, e.g. at the end of setup()?