Disabling the Garbage Collector

Jeroen Bollen jbinero at gmail.com
Sun Mar 2 15:21:48 PST 2014


On Sunday, 2 March 2014 at 23:17:12 UTC, bearophile wrote:
> 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

That'd mean that the garbage collector was initialized in the 
first place, wouldn't it?

Is there maybe a way to disable the garbage collector from 
running unless you explicitly call it?


More information about the Digitalmars-d-learn mailing list