[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can userdate have references to lua objects?
- From: "Peter Hill" <corwin@...>
- Date: Tue, 13 May 2003 14:14:18 +0800
Rici Lake:
> I think it is legitimate to say that never garbage collecting an
> unreferenceable object is a memory-leak, on the "if it looks like a duck
> and quacks like a duck then it might as well be a duck" principle.
> Or to put it another way, if I'm writing a full description of weak-keyed
> tables, I would add the caveat "If a weak key/value is reachable from its
> strong value/key, then neither object will be garbage collected." This is
> not much different from the caveats in reference-counted systems ("if two
> objects refer to each other, neither will be garbage collected")
Roberto Ierusalimschy:
> Of course you can. You only have to traverse the weak table. So it may
> look like a duck, but it does not quack ;-)
But that is true of *any* weak reference... if you scan its table before the
GC kills it you can find it & revive it. So under the scanning criteria no
weak reference quacks (ie, they can always be revived if the GC doesn't beat
you to them).
I have to support Rici on this. The situation does appear to be a circular
reference, something which GC's are expected to handle gracefully.
I think the issue of whether one should even be allowed to scan a weak-keyed
and/or weak-valued table should be seriously considered.
*cheers*
Peter Hill