by matthewinrw · 14y ago · 0 comments
The short answer is that SRAM is faster than DRAM, and you can be a lot stingier with memory in C++ and hence fit more into the fast type of RAM.
Stack-based allocation is not by any means an "advanced" technique, and is the absolute fastest form of memory management, full stop. It can deallocate an arbitrary number of objects in a single assembly instruction. Good C++ makes extensive use of the stack for this reason.
Stack allocated objects are densely packed into the L1 cache, making them faster than objects from an allocator which might spray them over the address space in suboptimal scenarios.
This absolute control over how memory is being used, (_when_ done well) is the difference between "gee that's pretty fast" and "wow".
No comments yet.