[BUG] loading new version of RB deletes important methods
Avi Bryant
avi at beta4.com
Thu Sep 18 22:13:58 UTC 2003
On Thu, 18 Sep 2003, Ned Konz wrote:
> Though some class initializer could do the checking and cleanup (which
> in this case would be to remove the registration of that WeakSet with
> WeakArray's finalization process.
Yes - though how long do you leave that cleanup code in for? Not that it
really matters...
> > The reason I was registering it in the first place was that I found
> > that for a WeakKeyDictionary, if I didn't register it with
> > WeakArray its items never got GCd. I guess I changed from a
> > WeakKeyDictionary to a WeakSet without removing that registration.
> > But I still don't entirely understand what's going on - when are
> > you *supposed* to use #addWeakDependent:?
>
> If items weren't getting GC'd it was probably because you'd killed off
> the finalization process.
Well, the finalization process wouldn't matter unless the dictionary was
registered as a weak dependent in the first place, right?
This is what I mean by not getting garbage collected:
Object allInstances size. "7"
dict := WeakKeyDictionary new.
dict at: 0 at 0 put: Object new.
Object allInstances size. "8"
Smalltalk garbageCollect.
Object allInstances size. "8"
dict finalizeValues.
Smalltalk garbageCollect.
Object allInstances size. "7"
So it seems to me that if I need the values collected in a
WeakKeyDictionary, I need to register it as a weak dependent, right?
More information about the Squeak-dev
mailing list
|