Download presentation
Presentation is loading. Please wait.
1
Jangwoo Shin (shinj@gradient.cis.upenn.edu) Garbage Collection for Real-Time Java
2
8/13/2001 What is real-time garbage collector? Memory Organization for KVM-RT Baker’s Tri-coloring Algorithm Implementational Details References Overview
3
8/13/2001 Incremental GC –Collector interleaved with mutator Constant Time-bound operations –Root scanning, evacuation, referencing Allocation time is proportional to size Efficiency –Trade-off between time and space –Compaction vs. non-compaction Real-Time GC
4
8/13/2001 Memory as collection of cells Objects in Memory = Directed Rooted Graph Header contains size and type + info – depends on the GC scheme used Memory as directed rooted graph Compaction or not? –Fragmentation occurs w/o compaction Memory Organization
5
8/13/2001 A variation of copy collector by Cheney [2] Memory divided into From- and To-space –All allocation goes into To-space only –From-space is read-only from mutator’s view –To-space is subdivided into: Object creation area(grows downward) Object evacuation area(grows upward) –Areas flipped when evacuation ends Tri-coloring by Baker [1]
6
8/13/2001 Reachable objects in From-space are incrementally scavenged and evacuated into To-space, then space flipped Read-barrier prevents mutator from accessing to objects in From-space At any moment, an object in memory: –White: used in From-space, but not scanned –Gray: scanned but not fully scavenged –Black: fully scavenged Tri-coloring[cont]
7
8/13/2001 Compared to other GC’s –Advantages: Exact(non-conservative) s.t. space-saving Compaction = no fragmentation –Disadvantages: Wastes half the memory, roughly High overload for copying Extra code for read-barrier Tri-coloring[cont]
8
8/13/2001 Basic operations and algorithm –Root-set scanning Evacuate referred objects –Referencing(read barrier) If object in From-space then return after evacuation –Evacuation Move an object from From- to To-space –Allocation Create object in To-space and evacuate all referred obj’s. –Scavenging While (scavenge-ptr < evacuation-ptr) if referred resides in From-space then evacuate and set forwarding pointer accordingly Implementation
9
8/13/2001 Implementation[cont] From-Space ADDR high mid+1 To-Space ADDR mid low allocation-ptr (grow downward) evacuation-ptr (grow upward) A. object gets evacuated to To-Space B. any back-references to the From-Space are scanned for scavenging root-set original object to be GC’d evacuated object referenced object C. scavenging copies referenced objects to To-space Fig. 1. Schematic diagram of GC algorithm scavenge-ptr
10
8/13/2001 Timing Analysis –Rootset scanning = O(size(rootset)) –Referencing = O(indirect reference) –Evacuation = O(cost of copy), can be mixed with mutator –Allocation = O(size(object)) –Scavenging= O(cost of copy) can be mixed with mutator –Flipping: O(change few pointer values) –Maximum pause: max of all above. Implementation[cont]
11
8/13/2001 Object = Header + Data –Header(32bit cell) 24 bit length field 6 bit type field 1 bit forward flag –Data Type and size specified by the header Contains To-space target when forwarded 2 byte tail attached if byte data Implementation[cont] header data Object-ptr
12
8/13/2001 Generational GC: using multiple sub- heaps, short-lived objects are collected more quickly and frequently [3] Baker’s Treadmill: non-copying, in-place collector using doubly linked lists [4] Extensions
13
8/13/2001 [1] H. Baker, List Processing for Resolving Conflicts in Dynamic Storage Allocation, CACM, 21(4):280-294, April 1978. [2] C. J. Cheney, A nonrecursive list compacting algorithm, CACM, 13(11):677-678, Nov. 1970. [3] H. Lieberman and C. Hewitt, A Real-Time Garbage Collector Based on the Lifetimes of Objects, CACM, 26(6):419-429, June 1983. [4] H. Baker, The Treadmill: Real-Time Garbage Collection Without Motion Sickness, ACM Sigplan Notices, 27(3):66-70, March 1992. [5] P. Wilson, Uniprocessor Garbage Collection Techniques, In Proceedings of the International Workshop on Memory Management St Malo, France, pp. 1-42 Springer-Verlag, September 1992, LNCS 637. Reference
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.