[squeak-dev] Suspiscious "weak" value reclaimed

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon Mar 26 19:07:41 UTC 2018


Hi all,
while porting MatFileReader to Squeak, I encountered this questionable
behaviour:

I create classes on the fly for holding Matlab struct().
I want those classes to be garbage collected when no more used.

If I store the classes in a WeakArray, then this should normally not work:
I mean that the classes should not be reclaimed.
Why?
Because the metaclass points strongly to the class (via thisClass variable).
And the metaclass can't be reclaimed either, because it still has an
instance.
That's what happens in Visualworks, classes put in a WeakArray are never
reclaimed.
Fortunately, there is some Ephemeron support in VW to work around this
(such loop are detected by ephemerons, and strong references by some object
ephemerely pointed to does not count).

In Squeak, I used a WeakValueDictionary, and to my surprise, discovered
that the classes were reclaimed.
Is this a bug?

Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20180326/9ac884c1/attachment.html>


More information about the Squeak-dev mailing list