32 Lifetime management

A DGS node only inserts itself into the DGS eviction queue if/when it first has the read barrier invoked. This sets the DF_IN_EVICTION_QUEUE bit.

While the node is in the eviction queue the containing IObject is visited and cannot be garbage collected by the CSpace GC.

A node can only be evicted by calling TryEvict()

Direct $dep/$indep members of classes

Consider an object that directly has $dep/$indep members. So destruction of the object is tied to the destruction of the DGS nodes it contains.

Node::OnEvict() is a no-op in this case. Indeed even though the node has been evicted it is possible that the containing object is not deleted by the GC (e.g. it may still be reachable) and the read barrier on the node is invoked again causing the node to go back into the eviction queue.

$dep/$indep members of maps

Tyically the (key,node) entry in the map is created as a result of get(key). The node is constructed and the read barrier is called. The latter causes the node to be inserted into the DGS eviction queue and the DF_IN_EVICTION_QUEUE bit is set.

While the node is in the eviction queue the containing object is visited and cannot be GC'd.

OnEvict() removes the (key,node) entry from the map.