[Gc] Delayed collection of objects?
Wed, 25 Jun 2003 03:31:49 +1000
On 24-Jun-2003, David Jones <email@example.com> wrote:
> Does the collector delay reclaiming memory for any reason?
Yes, in the sense that it doesn't necessarily do a full garbage collection
after every allocation. However, it will usually do a reasonable job of
running a full garbage collection when it needs to.
> I have an application that is consuming more memory than I'd like it to.
If you want to tweak the collector's heuristics so that it
garbage collects more often, you can do so by setting the
GC_free_space_divisor variable to a higher value -- see gc.h.
Or alternatively, you could try inserting explicit calls to GC_gcollect()
at strategic locations in your application.
> have added instrumentation code to it that demonstrates that objects that I
> have no further use for are surviving GC.
> The application is Tcl-based, so I can give interactive commands to drive my
> After upgrading to 6.2alpha6 and enabling the debug options, I get the
> % find_class_refs VerilogScope
> 0x816d6e0 0x816de60
> % gc_backtrace 0x816d6e0
> 0x816d6e0 (/usr/local/include/gc_cpp.h:269, sz=28)
> Caller at allocation:
> ##PC##= 0x8072cc0
> Reference could not be found
As it says in include/gc_backptr.h, you should call GC_gcollect()
immediately before invoking GC_print_backtrace(). Otherwise the
results are just going to indicate what was live at the last collection.
Fergus Henderson <firstname.lastname@example.org> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <https://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.