[Gc] Determining if pointer GC allocated

Hans Aberg haberg-1 at telia.com
Thu Dec 22 01:41:04 PST 2011

On 22 Dec 2011, at 01:07, Boehm, Hans wrote:

> IIRC, GC_base() is avoided on the most frequently exercised paths in the collector, though those do very similar things using essentially the same data structures.  But it is essentially a short piece of straight-line code, so it should indeed be quite fast.  Slight improvements are probably possible if you know that the argument is a base pointer.  If you assume the argument is a pointer to a valid object, GC_find_header() != 0 might be a bit faster, though it uses an interface that's not currently exported.

In the application I have in mind, one checks the reference of the user object. The gc.h header says that when debugging allocation, that is not the base pointer.


More information about the Gc mailing list