[Gc] running GC only on demand

mental at rydia.net mental at rydia.net
Wed Feb 23 08:05:33 PST 2005

Quoting Bojan ©ernek <bojan.sernek at tehnotek.si>:

> If I understand correctly, the GC runs collections in between
> alloc's (when it sees fit to do so). How can I disable this
> feature and make sure a GC happens only when I run it?

There's no separate "gc thread", so collection passes only happen
during (some) allocs or when explicitly requested via

That said, you can use GC_disable() to temporarily disable
collection under any circumstances (including calls to
GC_gcollect()), and GC_enable() to re-enable it.

Note that calls to GC_disable() are cumulative, so if e.g. it's
called twice GC_enable() will also have to be called twice to
re-enable collection.

Out of curiousity, why do you need to do this?


More information about the Gc mailing list