Disable GC entirely

Adrian Mercieca amercieca at gmail.com
Sat Apr 6 01:01:09 PDT 2013


Thanks for your very quick answer Vladimir.

> On Saturday, 6 April 2013 at 04:16:13 UTC, Adrian Mercieca wrote:
>> Hi,
>>
>> Is it possible to switch off the GC entirely in D? Can the GC be
>> switched off completely - including within phobos?
> 
> import core.memory;
> GC.disable();
> 
> However, most D code - including the runtime and standard library -
> assume that a GC is present, and thus may leak memory.

Guess that answers the question; even if I avoid the GC in my own code and 
disable it as you say, then the runtime and standard library will leak - 
rendering the whole thing as not-an-option.

So I'll either have to not use the runtime+standard libraries and 
implement all I'd need myself without GC or else stick to C++. The latter 
would be a pity because I really like D, but then in C++ I have full 
control and the performance is always good.

In my very simple test, the GC version of my program ran more than twice 
slower than the non GC version. I just cannot accept that kind of 
performance penalty.

Thanks.


More information about the Digitalmars-d mailing list