After running my sketch, I got a warning that it was low on dynamic memory and could cause stability issues. It is the first time that this message appears to me. Could someone tell me what dynamic memory is? Thank you
It isn't really dynamic memory, it's static memory, but it's describing memory used by the code you forgot to post.
The key words are dynamic, ie it changes as the program runs and memory ie where some data is stored. The data that is stored includes variables, arrays of variables etc used by your sketch
Other memory, such as where the compiled program is stored, does not change when the sketch is run.
If some of your variables do not change when the sketch is run, such as text that you print or a table of fixed values in an array then there are techniques available to put them in the program memory instead of dynamic memory
Large arrays and strings of characters are the usual culprits when it comes to using too much dynamic memory. It is important to use variables of the appropriate type for the data being held to avoid wasting memory
For further advice please post your full sketch here, using code tags when you do
Which Arduino board are you using ?
The compiler can figure out how much RAM you have used in your program. What remains is used for the stack and the heap. It has no way to calculate whether you have enough for those two things, so it uses some arbitrary limitation to warn you that there may be a problem.
"dynamic memory" holds all your variable values, including arrays, strings (if you have them) etc.
If you post your sketch someone might be able to provide some options for reducing your memory usage.
I actually figured it out already, I just wanted to understand a bit better what dynamic memory is. The warning appeared because I was saving too much data in arrays. But for the test I wanted to do, I didn't need that many either, so I just used less and it no longer gave me any trouble plotting the data on a screen, which is what I wanted to do.
I've already fixed it by decreasing the amount of data I store in the arrays, but thanks for the help and info! The board I am using is Arduino Uno
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.