Next: , Previous: , Up: Referable Objects   [Index]


4.2.7.6 Cycle Dismantling

A simple cycle dismantling method will traverse the list of the objects visited when cycle detecting and destroy the objects as it goes. Care must be taken when doing so, for if the references hold by one object are removed before the object itself some more cycle detection may be triggered by this late references removal. And the cycle dismantling will run endlessly, running cycle detection after cycle detection.

Yet another hindrance of cycle dismantling lies with the order in which objects are being destroyed, for an object cannot be destroyed while yet to be destroyed objects still hold references to it.

See Detecting Cycles.

Dealing with the former should be as straightforward as setting the associated reference count to zero or otherwise indicating that the object is not itself referred by other objects before proceeding with removal of the hold references. The latter would require to remove the references held by objects before removing the objects themselves. For all the objects, that is. Thus, the cycle dismantling algorithm will traverse the list of objects three times: the first to mark the objects as in the process of destruction, the second to remove all the references the objects hold, and the last time to actually destroy the objects.

The second traversal - the references removal one - might trigger more object destruction. The objects newly found to require destruction would be destroyed as for the previously found ones, marked as in the process of destruction, stripped of held references and finally destroyed. The last step would be delayed and merged into the third and final pass, the one actually destroying objects. Such need arise since references to these newly found (to require destruction) objects may be hold by the previously found objects, references not yet stripped since the second traversal has not yet completed.

The actual reference up tracing mechanics are struct x1f4_nodelink_type centered, the data type is the description of the hold reference.

See struct x1f4_nodelink_type.


Next: , Previous: , Up: Referable Objects   [Index]