Disabling the Garbage Collector
Adam D. Ruppe
destructionator at gmail.com
Sun Mar 2 18:33:48 PST 2014
On Sunday, 2 March 2014 at 23:21:49 UTC, Jeroen Bollen wrote:
> Is there maybe a way to disable the garbage collector from
> running unless you explicitly call it?
That's really the default. The GC in D runs if and only if you do
a GC allocation and there isn't enough memory in its existing
pool. Then it tries to do a collection to make room (and if that
fails, it asks the operating system for more memory to grow its
arena, and if that fails, it throws OutOfMemoryError).
If you call GC.disable, it just sets a flag to skip the try
collection step.
But, in any case, the GC doesn't sit around in the background
constantly running at random times. It only runs when you call on
it to allocate.
More information about the Digitalmars-d-learn
mailing list