incremental garbage collection l.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Incremental Garbage Collection PowerPoint Presentation
Download Presentation
Incremental Garbage Collection

Loading in 2 Seconds...

play fullscreen
1 / 12

Incremental Garbage Collection - PowerPoint PPT Presentation


  • 176 Views
  • Uploaded on

Incremental Garbage Collection. Baker’s Incremental Copying Collector. Nels Beckman nbeckman@scs.cmu.edu. Background. Two forms of memory: From Space: Contains the ‘white’ colored objects. To Space: Contains the ‘black’ and ‘grey’ colored objects. When it’s ‘time to garbage collect’.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Incremental Garbage Collection' - geraldine


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
incremental garbage collection

Incremental Garbage Collection

Baker’s Incremental Copying Collector

Nels Beckman

nbeckman@scs.cmu.edu

background
Background
  • Two forms of memory:
    • From Space: Contains the ‘white’ colored objects.
    • To Space: Contains the ‘black’ and ‘grey’ colored objects.
when it s time to garbage collect
When it’s ‘time to garbage collect’
  • Move the objects referenced by the roots into the ‘to space’
  • These roots include registers, global variables, stack, and instruction pointer

Root

Root

To Space

From Space

when it s time to garbage collect4
When it’s ‘time to garbage collect’
  • Move the objects referenced by the roots into the ‘to space’
  • These roots include registers, global variables, stack, and instruction pointer

Root

Root

To Space

From Space

(Forwardingpointers)

until all garbage is collected
Until All Garbage is Collected
  • Mutator and Garbage Collector threads alternate
during a gc turn
During a GC ‘Turn’
  • CG follows references from objects in to-space
  • Referred Objects are colored grey
  • When every reference from a grey object is grey, color that object black.

Root

Root

To Space

From Space

during a gc turn7
During a GC ‘Turn’
  • CG follows references from objects in to-space
  • Referred Objects are colored grey
  • When every reference from a grey object is grey, color that object black.

Root

Root

To Space

From Space

during a mutator turn
During a Mutator ‘Turn’
  • If mutator tries to get a reference to a ‘white’ object, that object is copied to the ‘from space.’
  • This way, the mutator never has a reference to a white object.

Root

Root

To Space

From Space

during a mutator turn9
During a Mutator ‘Turn’
  • If mutator tries to get a reference to a ‘white’ object, that object is copied to the ‘from space.’
  • This way, the mutator never has a reference to a white object.

Root

Root

To Space

From Space

during a mutator turn10
During a Mutator ‘Turn’
  • Also, if the mutator allocates an object, this new object goes in the to-space marked black.

Root

Root

To Space

From Space

malloc()

afterwards
Afterwards…
  • When all objects in the to-space are ‘black’, ‘white’ objects can be reclaimed.

Root

Root

To Space

From Space

summary
Summary
  • Baker’s incremental copying algorithm can be used for real-time garbage collection, because GC and mutator threads are intertwined (This algorithm uses a read barrier).
  • Caveats:
    • If mutator tries to reference many white objects in a row, performance slows because of all the copying.
    • Garbage Collection must finish before to-space is filled with newly allocated objects.