Disable GC entirely

Paulo Pinto pjmlp at progtools.org
Sat Apr 6 03:10:38 PDT 2013


Am 06.04.2013 10:01, schrieb Adrian Mercieca:
> 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.
>


D's GC is not as good as some other system programming languages like 
Oberon or Active Oberon, just to cite two examples from many.

However, does the current performance really impact the type of 
applications you are writing?

I'm asking because I always found the C and C++ communities always care
too much about micro optimizations in cases it does not matter. Coming 
from a polyglot background I never managed to grok that.

However there are cases where every byte and every ms matter, in those 
cases you are still better with C, C++ and Fortran.

--
Paulo


More information about the Digitalmars-d mailing list