3 ms·
> stack allocation is much, much faster than any sort of heap-based memory management. Is that true? I thought nursery allocation was usually as fast if not fa
by kasey_junk 10y ago
> stack allocation is much, much faster than any sort of heap-based memory management.
Is that true? I thought nursery allocation was usually as fast if not faster than stack allocations.
- johncolanduoni 10y agoThe allocation speed will be close; a bit worse since the pointer to the end of the current allocation buffer usually isn't in a register and a function call and range check is required. However the overall cost of handling that memory from start to finish is significantly higher than the stack even if it gets clobbered in the first nursery collection. Not because it is very high, but because stack allocation/deallocation is so very simple.
- klodolph 10y agoRange checks can be done by the MMU, they're basically free.
- deleted 10y ago[deleted]