[Gc] Changing ‘GC_should_collect’ to account for malloc’d memory

Ludovic Courtès ludo at gnu.org
Wed Mar 2 02:43:37 PST 2011


Hi Hans,

"Boehm, Hans" <hans.boehm at hp.com> writes:

> Presumably the test could be something like
>
> <iconv_t structs allocd since last GC>*<sizeof iconv_t etc.> greater than GC_get_heap_size()/N
>
> for some value of N, analogous to GC_free_space_divisor ?

Yes.  How exactly would applications let libgc know about this?

Still...

On Glibc, sizeof (iconv_t) == sizeof (void *), but an iconv_t is
associated with several KiB of data.  The exact amount of data is a
function of the encoding parameters passed to iconv_open since Glibc
opens several converters that will be used in sequence to perform the
requested conversion.

This is just to illustrate that it can be hard to guess how much heap is
consumed by libraries on our behalf.

The malloc hook would allow us to get this information, but the downside
is that it doesn’t tell us when those malloc’d regions will be freed.

Thanks,
Ludo’.



More information about the Gc mailing list