[Gc] GC_malloc vs GC_gcj_malloc

Boehm, Hans hans_boehm at hp.com
Tue Jan 6 13:48:47 PST 2004

GC_malloc tells the collector nothing about the location of pointers
in the resulting object.  Thus at least every word has to be considered
as a possible pointer.  It's the easiest to use.  In conjunction with
occasional use of GC_malloc_atomic, it's usually as fast as anything else,
but its performance is less robust; you are more likely to see occasional
problems, especially as you come close to exhausting the address space
on 32-bit machines. 

GC_gcj_malloc was really designed for the GNU static Java compiler.
It assumes that the first word of every object contains a pointer
to a method table (or other type descriptor) and the second word
of that is a "GC descriptor" which identifies the possible pointer
locations in the object.  (The details are somewhat adjustable, but only with
extreme caution.  The thread interactions are tricky.)

If you are writing C/C++ code by hand, you probably don't want to
use GC_gcj_malloc, though you may want to look at gc_typed.h instead.
If you are implementing a virtual machine for Java and/or .NET or something
similar, you probably should look at GC_gcj_malloc.

You can generate descriptors with GC_make_descriptor (see gc_typed.h).
The actual implementation is described somewhat in GC_mark.h.  Descriptors
can have four different formats.  The two low order bits identify the
variant (length vs. bitmaps vs. procedure vs. indirect per object).  You
probably only care about descriptor internals if you are writing a compiler
that generates mark descriptors for method tables (as gcc does for Java code).


> -----Original Message-----
> From: gc-bounces at napali.hpl.hp.com
> [mailto:gc-bounces at napali.hpl.hp.com]On Behalf Of vasantha selvi
> Sent: Tuesday, January 06, 2004 5:36 AM
> To: gc at napali.hpl.hp.com
> Subject: [Gc] (no subject)
> what is the significance of GC descriptors?
> What is the difference between GC_malloc and GC_gcj_malloc?
> It would very much help for if any body make me understand these two 
> aspects.
> Regards,
> VS
> _________________________________________________________________
> Win Sony Playstation. Win the new Nokia 6610. 
> https://go.msnserver.com/IN/40246.asp Jazz up your New Year 
> with Sprite!
> _______________________________________________
> Gc mailing list
> Gc at linux.hpl.hp.com
> https://linux.hpl.hp.com/cgi-bin/mailman/listinfo/gc

More information about the Gc mailing list