<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Bert,<br></div><div><br>On Jun 22, 2016, at 6:54 AM, Bert Freudenberg &lt;<a href="mailto:bert@freudenbergs.de">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>okay, but it still is a bug that I get an endless recursion. AFAICT the bug is in growMemoryByAtLeast: which does not grow the memory as requested.</div></div></div></blockquote><div><br></div>Do you have a reproducible case for me to look at? &nbsp;The fix I submitted fixes your original case. &nbsp;But you could try and fix it yourself. &nbsp;If the become: is two-way and fails with out-of-memory the failure code should ask to grow memory by the sum of the instance byte sizes. &nbsp;There us a bytesSzeOfInstance: method (or close) to compute the required space.<div><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 Wed, Jun 22, 2016 at 3:44 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">&nbsp;<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's how Spur works.&nbsp; Become is lazy; the two objects are turned into forwarders to copies of each other.&nbsp; If the two objects have the same byte size as heap objects (rounded up to 8 byte units) their contents can be exchanged.&nbsp; If they are not, two copies must be created and the two originals turned into forwarders to the copies.&nbsp; 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).&nbsp; 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.&nbsp; 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">&nbsp;<br><div dir="ltr">Hi Bert,<div><br></div><div>&nbsp; &nbsp; it was a regression in argument validation for become introduced in fixing argument validation for the one-way copy hash case.&nbsp; The code was erroneously checking that it had space to create copies of the input arguments, even though it was a one-way become.&nbsp; It's a copyHash become and that confused it.&nbsp; It's now fixed.&nbsp; I'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">&nbsp;<br><div dir="ltr">I'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&nbsp;&nbsp;#'insufficient object memory' 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 == #'insufficient object memory' 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;&nbsp;&nbsp;#(58576608 16777216 58576608)</div><div><br></div><div>58 MB are not enough, but it doesn'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&nbsp;</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,&nbsp;Eliot</div></span></div></div></div></div></blockquote></div><br></div></div></div>
</div></blockquote></div></div></div><br></blockquote></div><br></div></div></div>
</div></blockquote></div></div></body></html>