gccint: Invoking the garbage collector

1 
1 23.6 How to invoke the garbage collector
1 ========================================
1 
1 The GCC garbage collector GGC is only invoked explicitly.  In contrast
1 with many other garbage collectors, it is not implicitly invoked by
1 allocation routines when a lot of memory has been consumed.  So the only
1 way to have GGC reclaim storage is to call the 'ggc_collect' function
1 explicitly.  This call is an expensive operation, as it may have to scan
1 the entire heap.  Beware that local variables (on the GCC call stack)
1 are not followed by such an invocation (as many other garbage collectors
1 do): you should reference all your data from static or external 'GTY'-ed
1 variables, and it is advised to call 'ggc_collect' with a shallow call
1 stack.  The GGC is an exact mark and sweep garbage collector (so it does
1 not scan the call stack for pointers).  In practice GCC passes don't
1 often call 'ggc_collect' themselves, because it is called by the pass
1 manager between passes.
1 
1  At the time of the 'ggc_collect' call all pointers in the GC-marked
1 structures must be valid or 'NULL'.  In practice this means that there
1 should not be uninitialized pointer fields in the structures even if
1 your code never reads or writes those fields at a particular instance.
1 One way to ensure this is to use cleared versions of allocators unless
1 all the fields are initialized manually immediately after allocation.
1