1 / 19

Generational Garbage Collection

A Real-Time Garbage Collector Based on the Lifetimes of Objects Lieberman and Hewitt, CACM June 1983, pp 419-429. Curtis Dunham CS 395T Memory Management, Spring 2011. Generational Garbage Collection. Purpose: Obtain Memory by Reclaiming Garbage

trista
Download Presentation

Generational Garbage Collection

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Real-Time Garbage Collector Based on the Lifetimes of ObjectsLieberman and Hewitt, CACM June 1983, pp 419-429 Curtis Dunham CS 395T Memory Management, Spring 2011 Generational Garbage Collection

  2. Purpose:Obtain Memory by Reclaiming Garbage • Effort expended with no garbage found is wasted • Techniques covered so far are for whole heap • Copying: O(live objects) • Mark-Sweep: Mark also O(live objects), Sweep is O(allocated memory) • Pesky non-garbage data continuously copied, marked/swept-over, or marked/compacted, etc. Garbage Collection – A Review

  3. Most garbage comes from recently allocatedor “young” objects • Programming intuition backed up by empirical data • Example: map-filter-reduce paradigm in Lisp • Visual: pdf/cdf cartoons Looking For Garbage In The Right Place

  4. Goal: efficiency in the face of “infant mortality” • Pay-as-you-go: cheaper storage for short-lived objects than for long-lived objects • Goal: reclaim young, dead objects with minimal effort; i.e. without examining the whole heap • Stay away from O(heap size), O(heap objects) complexities • Shorter GC pause times! Wish List

  5. Baker (Copying) Review “Scavenging” Traced Untraced Evacuated objects New objects Fromspace Tospace

  6. Semi-space is wasteful of space Copies whole heap All objects treated the same,regardless of longevity But it’s not all thorns… Locality Compaction Baker Review (2)

  7. No Time Travel: Impossible to point to a newer object than oneself at object creation • i.e. all pointers initially point “backwards in time”,or are null • A pointer must be updated to point “forward in time”, from older to newer. Some Insights Towards A Solution

  8. Some Insights Towards A Solution (graphic) Roots We allocated in here for awhile, until it filled up. Then we started allocating over here. Imagine no forward pointers We only have to trace this space!Ignore the pointers to fogies. Regions Fogies Youngsters

  9. Pointers can be updated • Pointers will be updated • Pointers will inevitably point forward in time,across the region boundary • Solution:Track these troublesome forward pointers • We expect (hope for) them to be rare • Great things become possible (pruned heap traces) Murphy’s Law: Forever With Us

  10. Tracking Forward Pointers Roots We stillonly have to trace this space!Still ignoring the pointers to fogies, too. Honorary roots (for this region) Entry table Fogies Youngsters

  11. One, Two, Many Roots Allows an arbitrary number of regions called “generations” Oldest Older Old Young Younger Youngest

  12. Like Bakers algorithm (Copying),space is reclaimed through evacuation GC is initiated by condemning a region Region keeps same generation number,but increments its version number Condemnation condemnv. 4. to judge or pronounce to be unfit for use or service: to condemn an old building. 5. U.S. Law. to acquire ownership of for a public purpose, under the right of eminent domain: The city condemned the property. g0.v0 g1.v0 g2.v0 g3.v0 g4.v0 g5.v0 memory region VM GC region g5.v1

  13. Concurrent Condemnations g0.v1 g1.v1 g2.v2 g3.v2 g4.v3 g5.v4 g4.v3 g5.v5

  14. The heap structure is only time-based by practicality-driven convention; the real invariants revolve around pointer directions • Can put new objects anywhere • Gives system and user optimization opportunities • Region/Generation coalescing is possible Clarifications

  15. GC of Entry tables • Record generation/version of source pointer • Orthogonality of forward pointers and intra-region collection • Collecting younger regions more often • Weak pointers • Store in Entry table with Forward pointers • Scavenging stacks, globals Details Abound

  16. (other than this paper, cited on title slide) Richard Jones and Rafael Lins. Garbage Collection: Algorithms for Automatic Dynamic Memory Management. (Chapter 7) 1996. Previous slides by Rudy Depena (2009), Maria Jump (2003) Dictionary.com Unabridged Based on the Random House Dictionary, 2011. References/Resources/Acknowledgements

  17. Languages like Haskell also adopted another mitigating technique called deforestation • Originally called Listlessness by Wadler (1984) • Escape analysis, a type of static extent analysis • Has roots in call-graph reclamation schemes (Hudak 1981), closure allocation strategies (ORBIT paper, Kranz et al 1986) • Even if we can’t prove that a new object will die quickly, it probably will anyway – and for that, we have generational GC! Some interesting notes, Possible Discussion

  18. Empirical analysis?? • We think it should work… • “… future research plans include … [testing] the behavior of real programs” • “Judging [GC] algorithms is tricky” • “… we expect good performance…” • Heap reorganization • “Pointer length” • Region size – parallels with Immix • Relationship with incremental designs Discussion

  19. Tracing → Scavenging Semi-spaces (fromspace, tospace) → Regions corresponding to generations Flip (fromspace ↔ tospace) → Condemning a region Fromspace → Condemned region(s) Terminology Review (From Baker to here)

More Related