Hi Igor,<div><br></div><div>    I already explained the ratchet technique we use in VisualWorks which involves no delay and simply takes advantage of the fact that Smalltalk processes are cooperatively scheduled within priorities.  This both avoids creating a process per finalized object and avoids the finalization process stalling if there is an error in a finalizer.  What&#39;s not to like?</div>
<div><br></div><div>cheers</div><div>Eliot<br><br><div class="gmail_quote">On Thu, Nov 4, 2010 at 1:24 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><div></div><div class="h5">On 4 November 2010 21:58, Chris Muller &lt;<a href="mailto:asqueaker@gmail.com">asqueaker@gmail.com</a>&gt; wrote:<br>

&gt;&gt;&gt; Here, at each GC cycle, a &#39;dict finalizeValues&#39; will be sent,<br>
&gt;&gt;&gt; which leads to looping over 1000 entries.<br>
&gt;&gt;&gt; Add dict with 10000 entries, and you will loop over 10000 after each GC.<br>
&gt;&gt;<br>
&gt;&gt; You should never register WeakKeyDictionaries to the finalization process.<br>
&gt;&gt; They are not thread safe.<br>
&gt;&gt;<br>
&gt;&gt; Since the next VMs will support your new finalization scheme, I see no<br>
&gt;&gt; benefit from the delay.<br>
&gt;<br>
&gt; Igor, I know I&#39;m very late to this discussion but..  The other benefit<br>
&gt; to the Delay that your finalization scheme does not solve is the fact<br>
&gt; that there could be a lot of _registrants_ in WeakArray that need to<br>
&gt; be enumerated after every GC.<br>
&gt;<br>
&gt; Correct me if I&#39;m wrong, but your finalization fix only allows each<br>
&gt; individual registrant to &quot;clean quickly&quot; rather than do a full<br>
&gt; enumeration; is that right?<br>
&gt;<br>
&gt; If there are 5000 registrants in WeakArray, the delay would prevent<br>
&gt; enumerating 5000 elements after every GC unless 5 seconds have<br>
&gt; elapsed.  So we are we not best off with _both_ your finalization fix<br>
&gt; _and_ the delay...?<br>
&gt;<br>
<br>
</div></div>Yes. Usually, a weak array populated by weakregistry instances.<br>
And usually there are few of them.<br>
Of course it may pose a problem, if you put it on stress, like adding<br>
5000 registrants.<br>
And of course, new finalization does not addressing this problem.<br>
Because weak dependents<br>
work for different purpose: be notified upon each GC cycle.<br>
And particular registrant can do anything during hanling a<br>
notification. And it can be something completely unrelated to weak<br>
stuff.<br>
<br>
VM just signals a semaphore, when GC done. The rest is up to image<br>
what to do. I don&#39;t see what can be improved here.<br>
<br>
&gt;  - Chris<br>
<div><div></div><div class="h5">&gt;<br>
&gt;<br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br></div>