Next Previous Up Top Contents Index

2.9 The FINALIZATION module

finalize

Open generic function

Summary

Finalizes an object.

Signature

finalize object => ()

Arguments

object
An instance of <object>.

Values

None.

Library

common-extensions

Module

finalization

Description

Finalizes object.

You can define methods on finalize to perform class-specific finalization procedures. These methods are called finalizers.

A default finalize method on <object> is provided.

The main interface to finalization is the function drain-finalization-queue, which calls finalize on each object awaiting finalization. Objects join the finalization queue if they become unreachable after being registered for finalization with finalize-when-unreachable. However, you can call finalize directly if you wish.

Once finalized, object is available for reclamation by the garbage collector, unless finalization made it reachable again. (This is called resurrection; see Section 2.5.2.7 on page 17.) Because the object has been taken off the garbage collector's finalization register, it will not be added to the finalization queue again, unless it is resurrected. However, it might still appear in the queue if it was registered more than once.

Do not write singleton methods on finalize. A singleton method would itself reference the object, and hence prevent it from becoming unreachable.

See also

finalize, page 60.

finalize-when-unreachable, page 57

drain-finalization-queue, page 57

automatic-finalization-enabled?, page 55

automatic-finalization-enabled?-setter, page 56


Common Dylan and Functional Extensions - 31 Mar 00

Next Previous Up Top Contents Index