<div class="gmail_quote">On 7 April 2012 01:08, Rainer Schuetze <span dir="ltr"><<a href="mailto:r.sagitario@gmx.de">r.sagitario@gmx.de</a>></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>
<br>
On 4/6/2012 8:01 PM, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 4/6/2012 10:37 AM, Rainer Schuetze wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I hope there is something wrong with my reasoning, and that you could<br>
give me<br>
some hints to avoid the memory bloat and the application stalls.<br>
</blockquote>
<br>
A couple of things you can try (they are workarounds, not solutions):<br>
<br>
1. Actively delete memory you no longer need, rather than relying on the<br>
gc to catch it. Yes, this is as unsafe as using C's free().<br>
</blockquote>
<br></div>
Actually, having to deal with lifetime issues myself takes away the biggest plus of the GC, so I am a bit reluctant to do this.<div class="im"><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
2. Null out pointers & references when you are done with them. This<br>
helps reduce unwanted pinning of unused gc memory.<br>
<br>
3. Minimize use of global memory, as that is a major source of source of<br>
roots.<br>
</blockquote>
<br></div>
I don't think there are many places in the code where these hints might apply. Are there known ways of hunting down false references?<br>
<br>
Still, my main concern are the slow collections that stall the application when a decent amount of memory is used. Removing false pointers won't change that, just make it happen a little later.<br>
</blockquote></div><br><div>An obvious best-practise is to allocate in fewer-larger blocks. Ie, more compounds and aggregates where possible.</div><div>I also expect you are doing a lot of string processing. Using D strings directly? I presume you have a stack-string class? Put as many working strings on the stack as possible...</div>