4 ms·
What you may be missing is that the stack is a lot faster than the heap. First, stack allocations and de-allocations are extremely cheap. Allocating a known am
by maltalex 6y ago
What you may be missing is that the stack is a lot faster than the heap.
First, stack allocations and de-allocations are extremely cheap. Allocating a known amount of stack memory requires nothing more than moving a pointer. The same goes for de-allocation.
Second, accessing stack memory is typically a LOT faster than heap memory since it's continuous and can be loaded in big chunks into the CPU's cache.
- brundolf 6y agoThat's exactly why I'm wondering why we can't use it for more things :)