Finalization question

David T. Lewis lewis at mail.msen.com
Sat Jun 10 13:23:45 UTC 2006


I have a case in which I want to register objects for finalization
in order to ensure that external references (file handles on OS pipes)
are closed if the object has not been properly closed by its user.
I thought it would be a good idea to unregister these objects explicitly
when I know that they *have* been properly closed. This seemed
like a good idea because allowing weak registries to grow can be a
big performance problem, and I thought it would be good to keep
the registry as small as possible.

The result appears to be an occasional race condition in which the
finalization process attempts to remove an element that somebody else
(me) has removed from another process. At least I think that's what's
happening, see attached png of the debugger.

Is explicitly removing an object from the finalization registry a
Bad Thing To Do? Or is this perhaps a bug that should be resolved
by synchronizing access to the finalization registry, or by ignoring
the error condition in the finalization process?

Thanks,

Dave

-------------- next part --------------
A non-text attachment was scrubbed...
Name: FinalizationRaceCondition.png
Type: image/png
Size: 19948 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20060610/08557f6c/FinalizationRaceCondition.png


More information about the Squeak-dev mailing list