Thanks for your comment about the C and C++ language, and their use with Arduino.
Yes, I looked at the adafruit website here:
https://learn.adafruit.com/memories-of-an-arduino/measuring-free-memory
It got a description of this use of stack and heap area. As I read it, freeMemory() base its calculation on the actual stack pointer value, and not an observation of actual stack use over time. So I guess, that the user, when using freeMemory have to leave some space for the possible extra stack use.
I did some programming of microprocessors 30 years ago. At that time it was common practice, to set all RAM to 0HFF from very start at power up. Then you as part of the development had some code to check how much stack, that were used. With multi-task systems you had more stacks. Back then, the compilers did not support any calculation of stack use. But have this changed today? Or do you still have to test and perhaps make some guess of the amount of stack use?