Next Previous Up Top Contents Index

2.5.2 How the finalization interface works

2.5.2.1 Registering objects for finalization

Finalization works through cooperation with the garbage collector. Objects that are no longer referenced by the application that created them will eventually be discovered by Dylan's garbage collector and are then available to be reclaimed.

By default, the garbage collector reclaims such objects without notifying your application. If it is necessary to finalize an object before it is reclaimed, your application must inform the garbage collector.

The garbage collector maintains a register of objects requiring finalization before being reclaimed. To add an object to the register, call the function finalize-when-unreachable on the object. Objects on the register are said to be finalizable.

If the garbage collector discovers that a finalizable object is no longer referenced by the application, it does not reclaim it immediately. Instead, it takes the object off its finalization register, and adds it to the finalization queue.

The finalization queue contains all the objects awaiting finalization. The garbage collector will not reclaim the objects until they have been finalized.


Common Dylan and Functional Extensions - 31 Mar 00

Next Previous Up Top Contents Index