Help me grok addFinalizer

wagnerdm at wagnerdm at
Thu Feb 16 21:53:11 CET 2012

Quoting Antoine Latter <aslatter at>:

> On Thu, Feb 16, 2012 at 2:04 PM, Michael Craig <mkscrg at> wrote:
>> When I read the docs for System.Mem.Weak, it all seems to make sense. But
>> then this code doesn't run as I expect it to when I turn on
>> -threaded: (Expected/actual output are listed in the
>> paste.)
>> I've tried this on 7.4.1 and 7.0.4 with the same results. Can someone
>> enlighten me?
> First off, I'm pretty sure finalizers won't run until the data they
> were associated with has been GCd, and GHC doesn't do GCs unless there
> is allocation - threadDelay doesn't allocate much, I imagine.

This seems to be an explanation of why a finalizer might run later  
than expected (or not run at all). But his paste shows that it runs  
*earlier* than what he expected.


More information about the Glasgow-haskell-users mailing list