6 ms·
> A generational garbage collection is slower than freeing a stack frame, but has a lower per item overhead than calling `free()`. Almost, but not always. The
by ThatGeoGuy 10y ago
> A generational garbage collection is slower than freeing a stack frame, but has a lower per item overhead than calling `free()`.
Almost, but not always. The Cheney on the MTA [1] paper describes a generational GC where the first generation is the stack. So for collections on the first generation, collection is equivalent to clearing a stack frame.
[1] http://dl.acm.org/citation.cfm?doid=214448.214454 http://dl.acm.org/citation.cfm?doid=214448.214454
- belovedeagle 10y agoI don't think you quite understand the problem... The cost isn't in literally freeing objects but in doing the mark/{sweep,copy}. So Cheney's collection is not equivalent to decrementing the stack pointer. The only special things about the stack per se are a) arena[0] allocation and b) special ISA and OS support. When people say "stack allocation" the important points are (a) as well as c) static lifetime analysis. These are different concepts: Rust, for example, achieves (c) on the heap as well as the native stack. [0] I.e., three-pointer, although for the stack the OS manages at least one of them
- deleted 10y ago[deleted]