[Gc] Avoid GC_calloc-like semantics

Hans Boehm Hans.Boehm at hp.com
Sun Jul 17 22:59:12 PDT 2005

The current object clearing is actually done before the object is
allocated, at least for small objects.  Thus it would be hard to do this
for small objects.  (The benefit might also be less than you think, since
the initialization cost tends to be dominated by the cache misses.  And
that should generally happen just once either way.)

It probably wouldn't be hard to support for large objects, i.e. objects
larger than 2K or 4K depnding on the platform.  Would that help?


On Sun, 17 Jul 2005, Adam Warner wrote:

> Hello Hans,
> Thank you for your wonderful garbage collector that works in very hostile
> environments.
> GC_malloc is closer to calloc's semantics since it guarantees that
> allocated memory is cleared exactly like calloc. I have situations where I
> need to duplicate non-atomic allocations. Ordinarily this would consist of
> a malloc and a memcpy. Substituting GC_malloc for malloc leads to the
> allocation first being cleared before it is instantly filled via memcpy.
> Will you expose a non-atomic non-zeroing allocator as part of your public
> API? I suggest the name GC_malloc_nonatomic_nonzero, which is scary enough
> to stop people from using it before they understand its implications.
> Thank you,
> Adam
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> https://www.hpl.hp.com/hosted/linux/mail-archives/gc/

More information about the Gc mailing list