Under what conditions are finalizers not run?

Wolfgang Jeltsch g9ks157k at acme.softbase.org
Thu Nov 13 19:02:45 UTC 2014


the documentation of System.Mem.Weak under


says the following:

> It is not guaranteed that a finalizer will eventually run, and no
> attempt is made to run outstanding finalizers when the program exits.

In which situations are finalizers not run? I see that they might not be
run when the program ends while the weak pointer is still alive, but are
there also other situations? The above quote seems to say that even an
implementation that ignores any finalizers would conform to the API

I think it is actually quite bad if you do not have any guarantees about
when finalizers are run. In the memo table example, for instance, this
would mean that the memo table could grow very large, which would not
just result in bad space complexity, but also bad time complexity for

I am actually particularly interested in adding finalizers to IORefs.
Are there any stronger guarantees for finalizers attached to IORefs and

All the best,

More information about the Glasgow-haskell-users mailing list