Solution Mark specific object instances as requiring finalization. Such objects receive a death-bed notification from the memory manager, and can perform whatever tidying is necessary. There is no need to remove the finalization mark as the VM will already have done so. This reduces finalization overhead and allows objects to die sooner. The objects referenced from finalizable objects cannot be garbage collected until the objects have been finalized.
Finalization has considerable overhead relative to explicitly releasing resources.
Using the finalization of objects to maintain other data structures breaks encapsulation, and may require process synchronisation. Finalization is performed asynchronously at an unpredictable time after the last strong reference to an object has been removed. Furthermore finalization is performed after all weak references to an object have been removed by the garbage collector. Order of finalization may be significant, and may be difficult to guarantee where one finalizable object weakly references another since there is no notion of ownership. Known Uses GraphicsTool.