Finalizers and FFI
alastair at reid-consulting-uk.ltd.uk
Thu Jun 10 06:22:37 EDT 2004
> [program deleted]
> So, this basically means that my finalizer did not get run :(
> It should run, in separate thread or not, it doesn't matter here.
> Any ideas why doesn't it work?
Hopefully the GHC folk will correct me if I'm wrong but I think what happens
- you allocate object with finalizer
- the object becomes inaccessible
- performGC causes the object to be freed by the garbage collector
- the garbage collector schedules a thread to run your finalizer
- before the finalizer thread has a chance to be scheduled, your
You could give the finalizer thread a chance to run by calling
Control.Concurrent.yield before exiting:
That is, call yield just after calling performGC.
More information about the Glasgow-haskell-users