[Gc] running GC only on demand

Alec Orr Alec.Orr at wbemsolutions.com
Wed Feb 23 07:27:40 PST 2005

There are 3 functions in gc.h which you could use.  When you start your 
application, call GC_disable(), then make a function like so:

void MyExplicitGC(void) {

	/* (Re) Enable garbage collection  */

	/* invoke a full world stopped collection */

	/* Disable the GC, even GC_gcollect calls are in effective*/

To make sure GC's are happening when you expect, you can set the 
environment variable GC_PRINT_STATS=1 while your app runs.  The GC will 
log collection statistics as they happen.

Bear in mind that GC_enable() and GC_disable() calls are reference 
counted.  Two calls to GC_enable() and two calls to GC_disable() will 
disable garbage collection.  Two calls to GC_enable() and ONE call to 
GC_disable() means that garbage collection is still enabled.

Hope this helps,

Bojan Šernek wrote:
> 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?
> Thanks,
> Bojan Sernek.
> ------------------------------------------------------------------------
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4686 bytes
Desc: S/MIME Cryptographic Signature
Url : https://napali.hpl.hp.com/pipermail/gc/attachments/20050223/d3c65233/smime.bin

More information about the Gc mailing list