<br><br><div class="gmail_quote">On Tue, May 24, 2011 at 5:34 PM, Igor Stasenko <span dir="ltr">&lt;<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im"><br>
On 25 May 2011 00:51, Craig Latta &lt;<a href="mailto:craig@netjam.org">craig@netjam.org</a>&gt; wrote:<br>
&gt;<br>
&gt;<br>
&gt; Hi Igor--<br>
&gt;<br>
&gt;&gt; &gt; ...now I&#39;m looking forward to ephemeron conflicts. :)<br>
&gt;&gt; &gt;<br>
&gt;&gt;<br>
&gt;&gt; What conflicts?<br>
&gt;&gt;<br>
&gt;&gt; Please elaborate :)<br>
&gt;<br>
&gt;     Oh, none yet, I just suspect there will be some with the stuff I<br>
&gt; wrote to GC stale methods.<br>
<br>
</div>Yes. This could be a problem. Consider a following:<br>
<br>
MyClass&gt;&gt;someMethod<br>
  ^ #( &#39;abc&#39; &#39;def&#39; )<br>
<br>
<br>
ephemeron := Ephemeron new<br>
   key: self someMethod first<br>
   value: somethingElse.<br>
<br>
So, we created an ephemeron, whose key are object which came from<br>
method&#39;s literals. And even worse,<br>
as it shown above, it could be not a direct literal, but nested object.<br>
<br>
Now, if you GC this stale #someMethod , it will apparently turn<br>
ephemeron&#39;s value to be weakly referenced,<br>
and its key will be lost and replaced by nil.<br></blockquote><div><br></div><div>Uh, no.  The ephemeron refers to the string &#39;abc&#39; that happened to be referenced by the method.  But that string won&#39;t be garbage collected until there are no references to it in the system, including from the ephemeron.  i.e. the ephemeron will either need to nil its key or itself be collected before the &#39;abc&#39; string can be collected.  There is no magic here with references to objects from methods.  In Smalltalk, methods are just objects.  [and in the Cog VM there is a little bit of chicanery to preserve the illusion that there are no machien code methods involved, but that&#39;s what it does; hide the machine code].</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
To circumvent that, you have to make sure that all literals which kept<br>
by method are still reachable from roots by other means.<br>
Another approach is to detect and do something with such problematic<br>
ephemerons, but as example shows, this could be tricky.<br>
<br>
Btw this will happen with other weak refs as well.<br>
<br>
array := WeakArray with: self someMethod first.<br>
<br>
do you have a solution for that?<br>
<br>
Of course it depends on your intents.<br>
<div><div></div><div class="h5"><br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
</div></div></blockquote></div><br>