Re:A Programming Idiom You've Never Heard Of
by bunderbunder on Wednesday January 04, 2012 @11:26AM
(#3424674)
Nor is it particularly desirable. One of the cornerstones of how a modern generational GC performs as well as it does is that blocks of objects are freed up all at once.
If they were deallocated in a piecemeal fashion then:
- Freeing up memory would take longer, because you can't just change a pointer back to the root of the generation.
- Allocating memory would take longer, because it involves searching for a big enough empty slot rather than just throwing the new object on top of the heap.
- More memory is wasted overall, because of heap fragmentation.
If they were deallocated in a piecemeal fashion then:
- Freeing up memory would take longer, because you can't just change a pointer back to the root of the generation.
- Allocating memory would take longer, because it involves searching for a big enough empty slot rather than just throwing the new object on top of the heap.
- More memory is wasted overall, because of heap fragmentation.