Possible RAM problem

I have an interesting problem that my sketch behaves quite randomly. There is no repeatable errors. It writes random values to EEPROM at random times while it should not.

What I suspect, is that there is not enough RAM, as before I added NTP function, there was no random writings into EEPROM. After compiling a sketch it says that there is still 591 bytes available for local variables.
I have seen similar behavior with my other sketches.

Is there any real possibilities to see if there is truly not enough RAM? And how much RAM there is actually available?

See here.

You do know that RAM holds both the heap and the stack which can grow large.

I can't see your code to tell how much RAM you might save or not.

I can't see what board you have to tell how much RAM it has.

All I have to work from is a sketchy anecdote.

Code is magic of thinking...

So, no code = no thinking. Correct?

GRuser:
Code is magic of thinking...

So, no code = no thinking. Correct?

No, that would be "no code == no thinking"

A few years ago I tried to make a "High Water Mark" for the sketch, to actually measure how much memory is not used at all while the Arduino is running: HighWaterMark.ino.

You can add it to your sketch and let it run a few days and then check if there is still some unused memory. I have it running in a Arduino Uno and Arduino Mega 2560. It is informative to see the difference of what the compiler says and the actual value during runtime.

The value that it shows does not have to be the actual unused ram, because the heap might have large chunks that are not used and maybe the method that I use can find a wrong piece of "unused" memory.

When you say that your use NTP and have 591 bytes left, then I think that is not enough for a Uno or Mega 2560.

We know many ways to reduce memory usage, but then you have to show your sketch.

GRuser:
Code is magic of thinking...

So, no code = no thinking. Correct?

Maybe in some post-modernist delusion but there is no magic except to people who don't know any better.

I see a LOT of code on this forum that shows little real thought at all. In time they learn to think in logic and their code gets better and better -- I don't expect beginners to know the ropes.

This Arduino code is what you give the IDE to make a set of instructions for the chip to run, PERIOD.
If you do it right your project may run right (may, because the wiring could be less than right) otherwise keep trying or give up.

I'm not winging that, I started writing computer code for money in 1980.

Smartest thing a beginner can do is to NOT take on a big project until they have gotten comfortable with small projects and at least gotten past arrays and loops and hopefully learned that do-many-things-at-once lesson well.

Code is magic of thinking

That is OP's signature.

"no code"
is what OP has posted for his code (in tags ...etc), so far.

"So, no code = no thinking. Correct?"
is a comment just to show to OP, not to expect an answer (in other words, "thinking" by forum members) without posting a code.

I'm not winging that, I started writing computer code for money in 1980.

me too.!! That was assembly for 8085.

Company gave me interpreter Basic and in 82 or 83 DR's CB80. That's when I got an assembler but very little time to play, my shop duties took half my time or more. They could have hired a programmer but it would take longer to teach what I knew than for me to learn coding so I got another hat and a small raise.

Back in those days I learned Forth at home on a VIC-20 and that's the language that liberated my view.

groundFungus:
See here.

Thanks groundFungus, this makes sense. I will try to measure the amount of free memory.

Others, thank you for bothering yourself! I really did not expect so many replies and I did not ask to analyze my code, I asked for methods to measure free RAM.

Do you measure the stack --at every use-- oh magical one?

Because if you don't, you don't know how much RAM is left.