Weak references.
Jarrett Billingsley
kb3ctd2 at yahoo.com
Sun Apr 13 09:45:56 PDT 2008
"Frits van Bommel" <fvbommel at REMwOVExCAPSs.nl> wrote in message
news:ftsq01$f05$1 at digitalmars.com...
> Jarrett Billingsley wrote:
>> To both: yes, that's what I would have expected, but I can't seem to get
>> the object to be collected even if the only reference to it is a weak
>> reference. Tried forcing a full collect, allocating bunches of memory,
>> collecting again, allocating at the beginning of a long-running program
>> etc. it never seems to get collected, even if I never assign the
>> reference into an actual pointer type.
>>
>> I'm using Tango if it makes any difference.
>
> Have you tried looking at the generated assembler code? Perhaps the
> compiler is leaving a reference in some register that's never overwritten
> afterwards or something...
That's what I was thinking, which is why I tried running lots of code after
the allocation, to clear out the registers.
I've checked the memory block allocated for the WeakRef instance and it's
marked as "finalize" and "no scan", which are both right.
I absolutely cannot get it to collect the instance that it references.
I really wonder if this is a bug in the Tango GC.
More information about the Digitalmars-d
mailing list