From an SO answer1 about Heap and Stack, it raised me a question: Why it is important to know where the variables are allocated?
At anoth
I played a lot with a different benchmarks on stack and heap and I would conclude in following:
Similar performance for
Sligther better stack performance for (1x - 5x faster)
Much better performance for (up to 100x faster or even more)
The best aproach is array pooling. It is fast as stack, but you don't have such limitation like with stack.
Another implication of using stack is that it is thread-safe by desing.
Default memory limit for stack on x64 Windows is 4MB. So you will be safe with allocating not more than 3MB.