Finalizer problems..
mpringle@sfu.ca
mpringle@sfu.ca
Wed, 17 Jan 2001 7:41:11 PST
Didn't ghc 4.08-1 just come out in the last couple of months or so? Maybe
there have been some bug fixes that deal with this. Of course, maybe not.
cheers,
Micha
On Wed, 17 Jan 2001 03:08:48 -0800 simonmar@microsoft.com wrote:
> > > I would like to run some code when something is
> > > garbage-collected. Fine, he says, just the job for
> > > finalizers (module Weak). Unfortunately, they don't
> > > seem to offer a general solution, as the code below
> > > demonstrates (presumably, smallish things are copied,
> > > not shared, so that the finalizers run too early?).
> >
> > Yes, small Ints (approximately 30 bits worth) and Chars have a special
> > representation which makes it impossible to tell if they have
> > been GC'd
> >
> > GHC has a similar problem for Chars and small ints (-15..15 I think).
>
> GHC has similar problems for just about all types, due to agressive
> inlining and other optimisations. We've found that the only reliable
> types on which you can set a finalizer are the primitive heap-resident
> ones, like ForeignObj# and MutVar#. That's why using
> addForeignFinalizer is better than using the generic addFinalizer.
>
> We dreamed up various hacks to subvert the optimisations, but haven't
> found any clean solutions yet. The problem is one of "identity":
how to
> give an object a name such that you can refer to that particular object.
>
> Cheers,
> Simon
>
> _______________________________________________
> Hugs-Users mailing list
> Hugs-Users@haskell.org
> http://www.haskell.org/mailman/listinfo/hugs-users