Weak references.

Sean Kelly sean at invisibleduck.org
Mon Apr 14 10:23:31 PDT 2008


== Quote from Jarrett Billingsley (kb3ctd2 at yahoo.com)'s article
> "Sean Kelly" <sean at invisibleduck.org> wrote in message
> news:ftubv9$kph$1 at digitalmars.com...
> > == Quote from Jarrett Billingsley (kb3ctd2 at yahoo.com)'s article
> >> "Sean Kelly" <sean at invisibleduck.org> wrote in message
> >> news:fttd02$1mp1$1 at digitalmars.com...
> >> >
> >> > Are these tables AAs?  And how do the weak references store their
> >> > reference?
> >> > The type information provided to AAs is a bit weak, and so some
> >> > non-pointer
> >> > data is currently still scanned by the GC.  I'm going to improve this a
> >> > bit in the
> >> > next Tango release, but it still won't be perfect (because the compiler
> >> > doesn't
> >> > provide enough info for it to be).
> >> In my tests I've just been doing
> >> auto weakref = new WeakRef!(A)(new A);
> >> and then checking that after doing god-knows-what to try to get it to
> >> collect that instance of A, so it's not even that I'm doing anything that
> >> crazy.
> >
> > Just for kicks, try querying the GC to determine whether the GC thinks
> > weakref contains pointers.
> Already tried it.  The GC sees the weakref instance's memory as NO_SCAN and
> FINALIZE, both correct.

Huh.  Afraid I'm at a loss as to what's going on then.  Even stranger that it
works on linux but not Win32, since the code is basically the same for both.
I suppose I could add some profiling code to try and figure out where the
lingering reference is, assuming there is one.  But not sure when I'll have
the time to do this.


Sean



More information about the Digitalmars-d mailing list