Discussion on Go and D

Manu turkeyman at gmail.com
Fri Apr 6 15:44:55 PDT 2012


On 7 April 2012 01:08, Rainer Schuetze <r.sagitario at gmx.de> wrote:

>
>
> On 4/6/2012 8:01 PM, Walter Bright wrote:
>
>> On 4/6/2012 10:37 AM, Rainer Schuetze wrote:
>>
>>> I hope there is something wrong with my reasoning, and that you could
>>> give me
>>> some hints to avoid the memory bloat and the application stalls.
>>>
>>
>> A couple of things you can try (they are workarounds, not solutions):
>>
>> 1. Actively delete memory you no longer need, rather than relying on the
>> gc to catch it. Yes, this is as unsafe as using C's free().
>>
>
> 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.
>
>
>
>> 2. Null out pointers & references when you are done with them. This
>> helps reduce unwanted pinning of unused gc memory.
>>
>> 3. Minimize use of global memory, as that is a major source of source of
>> roots.
>>
>
> 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?
>
> 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.
>

An obvious best-practise is to allocate in fewer-larger blocks. Ie, more
compounds and aggregates where possible.
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...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120407/17a469fb/attachment.html>


More information about the Digitalmars-d mailing list