[Gc] RE: how to get the gc allocated bytes?
hans.boehm at hp.com
Fri Dec 14 17:02:31 PST 2007
> -----Original Message-----
> From: Achilleas Margaritis [mailto:axilmar at otenet.gr]
> Sent: Friday, December 07, 2007 2:39 AM
> To: Boehm, Hans
> Cc: Achilleas Margaritis;
> gc-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
> Subject: Re: how to get the gc allocated bytes?
> O/H Boehm, Hans έγραψε:
> > Probably your best bet is to run a program that just calls
> GC_gcollect a couple of times with the GC_PRINT_STATS or
> GC_PRINT_VERBOSE_STATS environment variable set. For gc7,
> this will print the amount of live memory found in the heap.
> This might include some blacklisted pages as atomic reachable
> memory, though probably not if you don't allocate anything.
> > In general, the collector allocates a few, usually small,
> data structures in its own heap. I wouldn't expect these to
> be terribly significant unless you have an almost empty heap,
> you have a very large number of threads, or there are a high
> proportion of finalizable objects or "disappearing links".
> > The heap is grown in much larger, though initially not
> huge, increments. And the collector explicitly expands the
> heap to its initial size at startup.
> > Hans
> >> -----Original Message-----
> >> From: gc-bounces-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
> [mailto:gc-bounces-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org]
> >> On Behalf Of Achilleas Margaritis
> >> Sent: Sunday, December 02, 2007 1:09 PM
> >> To: gc-o/PNRNCSakrWxDs0y9d3MAC/G2K4zDHf at public.gmane.org
> >> Subject: [Gc] how to get the gc allocated bytes?
> >> I call GC_gcollect() and then I call GC_get_heap_size(), but the
> >> result is not 0. How can I know how many bytes are
> allocated by the
> >> collector?
> >> _______________________________________________
> >> Gc mailing list
> >> Gc-V9/bV5choksm30D7ZfaTJw at public.gmane.org
> >> http://www.hpl.hp.com/hosted/linux/mail-archives/gc/
> But I still do not know how to get the number of bytes
> allocated by the gc. I don't want to print statistics, I want
> to know programmatically how many bytes are allocated at each
> point in time.
> I've got to write a new version of a commercial application
> and I would like to use the collector, but the customer
> insists that I track memory allocation precisely (hint: the
> contract is for the military, and there are some very strict
The collector (v7+) tracks the total bytes traced at the last GC in GC_composite_in_use and GC_atomic_in_use. These are not currently client accessible. (They're really struct elements of GC_arrays.) It wouldn't be hard to add an accessor function. But this is only accurate as of the last GC, and it exclude some GC meta-information allocated outside the collectable heap, e.g. the headers for heap chunks.
More information about the Gc