0
Stack flow
Hi We all know that function code goes into code section of memory. Also memory which is not allocated by new operator goes into stack. So, does this mean that during programme run, we are indirectly allocating memory on stack also ?
3 Antworten
+ 3
Yes this is called static memory allocation.
Dynamic and Static both jobs are done by the compiler.
Also access to static memory is very fast.
+ 3
We know how much stack space a function will need, at compile time, so it's not really the same kind of allocation like with heap space.
There is a max stack size and you can fit many "stack frames" in there, but if your stack frames are very large or you recurse very deeply then you will run into overflow and there is no resizing the stack like an std::vector.
+ 2
yes, which is why the term “stack overflow” exists.