<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><font face="Georgia">Other that the WeakValueDictionary, is there
anything referencing either the class or metaclass? If not, then
they would be collected. Perhaps VW is saving a reference
elsewhere?</font><br>
</p>
<br>
<div class="moz-cite-prefix">On 3/26/18 3:07 PM, Nicolas Cellier
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAKnRiT658T6_rR_OvBFD5t9ko7R8Op6M+ns9ROHMcF9Wvo3psA@mail.gmail.com">
<div dir="ltr">
<div>
<div>
<div>
<div>
<div>
<div>
<div>Hi all,<br>
</div>
while porting MatFileReader to Squeak, I encountered
this questionable behaviour:<br>
<br>
</div>
I create classes on the fly for holding Matlab
struct().<br>
</div>
I want those classes to be garbage collected when no
more used.<br>
<br>
</div>
If I store the classes in a WeakArray, then this should
normally not work:<br>
</div>
I mean that the classes should not be reclaimed.<br>
</div>
Why?<br>
Because the metaclass points strongly to the class (via
thisClass variable).<br>
</div>
<div>And the metaclass can't be reclaimed either, because it
still has an instance.<br>
</div>
<div>That's what happens in Visualworks, classes put in a
WeakArray are never reclaimed.<br>
</div>
<div>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).<br>
<br>
</div>
<div>In Squeak, I used a WeakValueDictionary, and to my
surprise, discovered that the classes were reclaimed.<br>
</div>
<div>Is this a bug?<br>
<br>
</div>
<div>Nicolas<br>
</div>
<div><br>
<br>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">
</pre>
</blockquote>
<br>
</body>
</html>