[Gc] Basic questions

Boehm, Hans hans_boehm@hp.com
Wed, 14 May 2003 10:24:58 -0700

> -----Original Message-----
> From: Emmanuel Stapf [ES] [mailto:manus@eiffel.com]
> Thanks for the detailed explanation. I feel that one could 
> make GC_malloc
> determine whether or not it should use its default 
> implementation or if it should
> be calling GC_malloc_ignore_off_page. The choice could be 
> made based on runtime
> configuration, no?
The problem is that when you use GC_malloc_ignore_off_page(), you
promise that a pointer to (near) the base of the object will be
stored someplace where it's visible to the GC.  That's not required for
a GC_malloc() call.  Thus it's not 100% safe to quietly turn a GC_malloc()
call into a GC_malloc_ignore_off_page() call, though it will probably work
99.8% of the time.

The GC_malloc_ignore_off_page() code in fact just calls GC_malloc() if you
use it to allocate a small object, for which the distinction doesn't matter.
Thus if you know that the appropriate base pointer is maintained, but you
are unsure of the object size, it's always fine to call GC_malloc_ignore_off_page().