Presentation is loading. Please wait.

Presentation is loading. Please wait.

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,

Similar presentations


Presentation on theme: "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,"— Presentation transcript:

1 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

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. 2

3  Most garbage comes from recently allocated or “young” objects  Programming intuition backed up by empirical data  Example: map-filter-reduce paradigm in Lisp  Visual: pdf/cdf cartoons 3

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! 4

5 5 New objects Evacuated objects Traced TospaceFromspace Untraced “Scavenging”

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 6

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. 7

8 8 YoungstersFogies Roots Imagine no forward pointers We only have to trace this space! Ignore the pointers to fogies. We allocated in here for awhile, until it filled up. Then we started allocating over here. Regions

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) 9

10 10 YoungstersFogies Roots Entry table Honorary roots (for this region) We still only have to trace this space! Still ignoring the pointers to fogies, too.

11 11 YoungestOldest Roots OlderOldYoungerYoung Allows an arbitrary number of regions called “generations”

12 12 g0.v0g1.v0g2.v0g3.v0g4.v0g5.v0 g5.v1  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 condemn v. 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. memory region GCregion VM

13 13 g0.v1g1.v1g2.v2g3.v2g4.v3g5.v4 g5.v5g4.v3

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 14

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 15

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. 16

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! 17

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 18

19  Tracing → Scavenging  Semi-spaces (fromspace, tospace) → Regions corresponding to generations  Flip (fromspace ↔ tospace) → Condemning a region  Fromspace → Condemned region(s) 19


Download ppt "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,"

Similar presentations


Ads by Google