<div dir="ltr">Hi, Eliot,<div><br></div><div>why not trimming the object (if its size allows it) to mark rest of now-forwader object to be a freespace immediately? </div><div>Like that you can avoid stressing memory too much by doubling amount of memory needed per each forwaded object involved in become operation.<br>And that, of course, if direct contents swap is not possible.<br><div class="gmail_extra"><br><div class="gmail_quote">On 22 June 2016 at 16:44, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@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"> <br><div dir="auto"><div>Hi Bert,<br><br></div><div><br>On Jun 22, 2016, at 5:57 AM, Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><span></span></div></blockquote><blockquote type="cite"><div><div dir="ltr">Hi Eliot,<div><br></div><div>the become-forward works now, indeed.</div><div><br></div><div>But why is it different with the swapping become? This still gets into an endless recursion:</div><div><br></div><div>(ByteString new: 20000000) become: (WideString new: 20000000)<br></div><div><br></div><div>Why is it creating copies at all?</div></div></div></blockquote><div><br></div>because that&#39;s how Spur works.  Become is lazy; the two objects are turned into forwarders to copies of each other.  If the two objects have the same byte size as heap objects (rounded up to 8 byte units) their contents can be exchanged.  If they are not, two copies must be created and the two originals turned into forwarders to the copies.  Remember the slides from my Cambridge talk.<div><br></div><div>Spur chooses to trade memory (creating the copies) over time (searching the entire heap looking fir references).  This is the right trade off until you start becoming objects that are substantial fractions of the entire heap in size.</div><div><br></div><div>In your case you could avoid the pain simply by making sure the steam had a wide String as contents in the first place.  I understand that may not be possible.<br><div><br><blockquote type="cite"><div><div dir="ltr"><div><br></div><div>- Bert -</div><div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jun 20, 2016 at 10:36 PM, Eliot Miranda <span dir="ltr">&lt;<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr">Hi Bert,<div><br></div><div>    it was a regression in argument validation for become introduced in fixing argument validation for the one-way copy hash case.  The code was erroneously checking that it had space to create copies of the input arguments, even though it was a one-way become.  It&#39;s a copyHash become and that confused it.  It&#39;s now fixed.  I&#39;ll generate sources and push and new builds should appear shortly ;-)</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jun 16, 2016 at 5:11 AM, Bert Freudenberg <span dir="ltr">&lt;<a href="mailto:bert@freudenbergs.de" target="_blank">bert@freudenbergs.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><div dir="ltr">I&#39;m reading a 20MB text file. At some point it tries to convert the 20 MB ByteString into an 80 MB WideString using forward become. This fails resulting in an endless loop. The primitive failure code for elementsForwardIdentityTo: (primitive 72) is  #&#39;insufficient object memory&#39; and it tries again after growing:<div><span style="white-space:pre-wrap"><br></span></div><div><span style="white-space:pre-wrap">        </span>ec == #&#39;insufficient object memory&#39; ifTrue:<br></div><div><div><div><span style="white-space:pre-wrap">                </span>[Smalltalk garbageCollect &lt; 1048576 ifTrue:</div><div><span style="white-space:pre-wrap">                        </span>[Smalltalk growMemoryByAtLeast: 1048576].</div><div><span style="white-space:pre-wrap">                </span> ^self elementsForwardIdentityTo: otherArray].</div></div><div><br></div><div>but the growMemoryByAtLeast: does not actually grow the memory:</div><div><br></div><div><div><span style="white-space:pre-wrap">        </span>{Smalltalk garbageCollect.</div><div><span style="white-space:pre-wrap">        </span>Smalltalk growMemoryByAtLeast: 1048576.</div><div><span style="white-space:pre-wrap">        </span>Smalltalk garbageCollect.}</div></div><div><br></div><div>==&gt;  #(58576608 16777216 58576608)</div><div><br></div><div>58 MB are not enough, but it doesn&#39;t grow any further.</div><div><br></div><div>The question is, why does it try to allocate a new object at all? The WideString exists already. I thought Spur would simply install a forwarder?</div><div><br></div><div>To reproduce, execute </div><div><br></div><div><span style="white-space:pre-wrap">        </span>(ByteString new: 20000000) writeStream nextPut: (Character value: 128169)<br></div><div><br></div><div>You probably want to follow that with a user interrupt (Cmd-period).</div><div><br></div><div>This happens using the latest Spur VM from github (r201606160944)</div></div><div><br></div><div>- Bert -</div></div>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div data-smartmail="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div></div></blockquote></div><br></div></div></div>
</div></blockquote></div></div></div><br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Best regards,<br>Igor Stasenko.</div>
</div></div></div>