[plt-scheme] removing a finalizer
At Tue, 31 Aug 2004 05:21:03 -0400, "Neil W. Van Dyke" wrote:
> How do I remove a finalizer
> that's been registered via "scheme_register_finalizer"?
You can use scheme_register_finalizer() again with NULLs to de-register
the finalizer.
> Should I use "scheme_remove_all_finalization"?
> It's in the source code, but doesn't seem to be in "Inside MzScheme".
If the relevant object is accessible from Scheme, then the problem with
using scheme_remove_all_finalization() is that someone may have
attached to a will to the object using `will-register', in which case
scheme_remove_all_finalization() removes that will in addition to your
finalizer.
I've added documentation for scheme_remove_all_finalization().
I see one problem with scheme_register_finalizer() and NULLs. In the
case where no other finalizers/wills are associated with the object, a
do-nothing low-level finalizer remains associated with the object. I've
fixed that for v299.15.
Meanwhile...
> (The finalizer frees an external resource if the programmer forgets.
> When the programmer properly frees the resource, I'd like to remove the
> finalizer, to avoid accumulating hundreds or thousands of them.)
Is this object registered with the custodian? It sounds like it should
be.
If it's registered with the custodian so that a close is required, then
the object will never be finalized, because the custodian will hold
onto the object.
If it's registered to not require a close by the finalizer, then the
custodian leaves another do-nothing finalizer behind. I've fixed that
for v299.15, too.
Matthew