Stack and heap memory - what is used where
Posted: Mon Sep 11, 2017 4:11 pm
Hi!
currently I'm working on a quite big project using a ESP8266.
So far I've managed to sort out many issues and I'm very happy at the moment because everything works like a charm
However I was wondering, what takes up stack and what takes up heap space.
Somewhere I've read that global variables (that is, for me, variables defined outside of any function, right?) are in the heap and local variables (that is, for me, variables defined INSIDE of functions, right?).
is that true?
I'm wondering because I'm hitting the stack limit a bit and I'm having multiple large buffers defined within functions, all about 1000 to 3500 bytes large, maybe about 5 or 6 of them all together.
to avoid hitting the stack, I wanted to define one big buffer on the top of my ino file and use that buffer over and over from all of my functions.
however, when I did that, everything started to act weirdly, as if I had memory corruption somewhere or as if I was running out of memory.
Is that expected, am I missing something? Or should it work and I have to have a mistake in my code somewhere else?
Directions, please
regards
mamama1
currently I'm working on a quite big project using a ESP8266.
So far I've managed to sort out many issues and I'm very happy at the moment because everything works like a charm
However I was wondering, what takes up stack and what takes up heap space.
Somewhere I've read that global variables (that is, for me, variables defined outside of any function, right?) are in the heap and local variables (that is, for me, variables defined INSIDE of functions, right?).
is that true?
I'm wondering because I'm hitting the stack limit a bit and I'm having multiple large buffers defined within functions, all about 1000 to 3500 bytes large, maybe about 5 or 6 of them all together.
to avoid hitting the stack, I wanted to define one big buffer on the top of my ino file and use that buffer over and over from all of my functions.
however, when I did that, everything started to act weirdly, as if I had memory corruption somewhere or as if I was running out of memory.
Is that expected, am I missing something? Or should it work and I have to have a mistake in my code somewhere else?
Directions, please
regards
mamama1