[BUG] loading new version of RB deletes important methods

Ned Konz ned at bike-nomad.com
Thu Sep 18 22:25:36 UTC 2003


On Thursday 18 September 2003 03:13 pm, Avi Bryant wrote:
> 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...

Would it work to have an otherwise empty class with an initialize 
method that just does some work and deletes itself?

> > > 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?

Yes, otherwise the association doesn't get deleted. However, this is 
not the case for a WeakSet or WeakArray.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE



More information about the Squeak-dev mailing list