-nogc

Daniel Keep daniel.keep.lists at gmail.com
Thu Apr 23 04:40:55 PDT 2009



Christopher Wright wrote:
> Andrei Alexandrescu wrote:
>> I've discussed something with Walter today and thought I'd share it here.
>>
>> The possibility of using D without a garbage collector was always
>> looming and has been used to placate naysayers ("you can call malloc if
>> you want" etc.) but that opportunity has not been realized in a seamless
>> manner. As soon as you concatenate arrays, add to a hash, or create an
>> object, you will call into the GC.
>>
>> So I'm thinking there should be a flag -nogc that enables a different
>> model of memory allocation. Here's the steps we need to take:
> 
> This means replacing a mark/sweep GC with a reference counting GC. I'd
> think that it would be better to have -nogc not use Ref(T) by default,
> and add another flag -refcount that implies -nogc and uses Ref(T) by
> default.

A thought occurs.  If you wanted to implement, say, a moving collector,
it would be very useful to have some level of indirection instead of
direct references (either using an ID for the actual address, or by
using an opPostMove to notify the GC, if we ever get one.)

So perhaps you could make "-nogc" alias to "-nogc=object_nogc", thus
allowing people to replace Array(T), AA(K,V) and Ref(T) with their own.

  -- Daniel



More information about the Digitalmars-d mailing list