Skip to content

Latest commit

 

History

History
33 lines (22 loc) · 1.14 KB

2014-04-18.md

File metadata and controls

33 lines (22 loc) · 1.14 KB

Kashyap

Collaborative Vim Editing:

https://github.com/FredKSchott/CoVim

Hemant

Write Barriers in Generational Garbage Collections

A generational garbage collector requires write barriers because when HEAP is split into young and old and younger generation needs GCed more often, there is a potential problem that - an object in young generation may be referened by an object in old generation.

So to mark a object in young generation for garbage collection, we must ensure that:

a. No other object references this object in younger generation. b. No other object references this object from older generation.

But traversing all of old generation just for checking if an object in old generation holds reference to this object defeats the point of generational GC.

Thats where Write barriers or remembered Sets come in. What is done here is, whenever a new object is referenced by an object in old generation such as:

old_hash["name"] = "Codemancers tech"

the hash is marked in an area called write barrier (or remembered set). This way, objects in remembered set are scanned in addition to objects in younger generation during minor GC.