<div dir="ltr"><div>Thanks a lot Bil! That was quick.</div><div><br></div><div>I just went on testing it and sadly the scenario I had described initially sees no improvement at all.</div><div>(and yes, I&#39;m calling s7_free instead of free heh)</div><div><br></div><div>If it&#39;s of any help, here&#39;s another scenario where the behavior is kind of weird</div><div>(it was like this even before this patch actually)</div><div><br></div><div>    for (int i = 0; i &lt; 10; i++) {<br>        s7_scheme *sc = s7_init();<br>        aod::s7::bind_all(sc);<br><br>        for (int j = 0; j &lt; 10; j++) {</div><div>            // 10 times creating a ~10mb string<br></div><div>            s7_eval_c_string(sc, //<br>                             &quot;(define x ((aod.c.foreign &#39;new-char[]) 10000000))&quot; // 10 mb<br>                            );<br>        }<br>        s7_eval_c_string(sc, &quot;(gc)&quot;);<br>        s7_eval_c_string(sc, &quot;(gc)&quot;);<br><br>        s7_free(sc);<br>    }</div><div><br></div><div>So, 10 loops of 10 times ~10mb.</div><div>After this first inner loop (10 times 10mb char*),</div><div>Before the first (gc) call I notice the memory usage jump from 18mb (init) to 113mb ( + ~100mb as expected)</div><div>- 1st call to (gc) has no effect</div><div>- After the 2nd (gc) call, I see the memory usage dropping to 28mb</div><div><br></div><div>Then, the s7_free has no effect at all.</div><div>Then, in any subsequent loop (i=1,2...) the (gc) call has no immediate effect!</div><div>The memory however doesn&#39;t increase as much in each loop, guess certain memory is being</div><div>reused.<br></div><div><br></div><div>Now, if I skip the (gc) calls, the memory once more tends to grow 100mb per outer loop.</div><div><br></div><div>If I leave one (gc) call, I&#39;m back to where in the first outer loop ~100mb are free and then</div><div>in subsequent loops the memory doesn&#39;t increase as much.</div><div><br></div><div>:::::::</div><div>Hope this isn&#39;t too confusing.</div><div><br></div><div>What seems to happen:</div><div>2 calls are needed to the (gc) to have any effect. In my scenario where I call only once the (gc),</div><div>the thing is that s7_free also calls once g_gc(sc, sc-&gt;nil);</div><div><br></div><div>And, again, note that in my original snippet (where I only create 1 big object), s7_free seems to have</div><div>no effect (the (gc) calls neither)</div><div><br></div><div><br></div><div>Hope this is kind of useful.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, 12 Sep 2020 at 11:46, &lt;<a href="mailto:bil@ccrma.stanford.edu">bil@ccrma.stanford.edu</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">I think s7_free is usable now.  I also have a valgrind<br>
suppressions file for it which I could include in the<br>
s7 tarball if it seems useful.<br>
<br>
</blockquote></div>