Disabling the Garbage Collector

bearophile bearophileHUGS at lycos.com
Sun Mar 2 15:17:11 PST 2014


Jeroen Bollen:

> I've read about ways to disable the garbage collector, but 
> that'd
> mean it was initially enabled.

You can disable and then enable the garbage collector like this:

void main() {
     import core.memory;
     GC.disable;
     // Do stuff here.
     GC.enable;
}

But if you perform GC-managed operations, they will not free 
their memory, like array appending, array concat, inserts in 
associative arrays, and so on.

You can also stub away the GC in a more complex way.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list