Disable GC entirely

Vladimir Panteleev vladimir at thecybershadow.net
Fri Apr 5 21:33:38 PDT 2013


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.

> What I am looking for is absolute control over memory 
> management.
> I've done some tests with GC on and GC off and the performance 
> with GC is
> not good enough for my requirements.

The GC will not be invoked unless you allocate memory (either 
explicitly, using "new", or using D's features which do so, such 
as dynamic arrays and closures). If you do not make use of those 
features, no GC code will run.


More information about the Digitalmars-d mailing list