[Gc] Re: Avoid GC_calloc-like semantics

Adam Warner lists at consulting.net.nz
Mon Jul 18 02:09:10 PDT 2005

On Sun, 17 Jul 2005 22:59:12 -0700, Hans Boehm wrote:

> 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 depending on the platform.  Would that help?

[A non-zeroing GC_malloc]

Thanks for the explanation about small objects. While it's only a
performance optimisation I believe being able to skip the zeroing of
larger objects when you know the object is going to be immediately filled
would improve the API. However I've realised there is an additional
complication: since slightly more memory may be allocated than requested
the allocator may still have to ensure that any overallocation is zeroed.

David Jones: I understand that clearing the block before returning it
guarantees that there won't be any false pointers in the newly allocated
block. But there is almost no point in zeroing it if you immediately
rewrite all those zeros.

Hans, please just treat this as a suggestion to improve the API. It's
neither required nor urgent.


More information about the Gc mailing list