[Gc] for C++ GC

Boehm, Hans hans.boehm at hp.com
Mon Aug 16 18:00:40 PDT 2004

In your example the resulting object should be collectable.

The only difference is likely to arise if a class provides its own operator new.

Also note that 

new(UseGC) test;

is likely to be safer than

new(GC) test;

since the identifier GC is often used for other purposes.

This stuff is all implemented in gc_cpp.h and gc_cpp.cc, which are relatively
short, and can be understood without understanding the rest of the collector.
(Unfortunately, these files also tend to be relatively unportable, since
compiler implementors still don't seem to completely agree on the details of
operator new overloading.)

-----Original Message-----
From: gc-bounces at napali.hpl.hp.com [mailto:gc-bounces at napali.hpl.hp.com]On Behalf Of Wei Bing
Sent: Friday, August 13, 2004 11:59 PM
To: gc at napali.hpl.hp.com
Subject: [Gc] for C++ GC

Dear all,

I have one question on C++ GC:

struct test
         int a;
         int b;

new(GC) test;   //collectable?

Why only the class inherited from gc or gc_cleanup can be collectable one?
I know "new(GC) int" can be collected, is there any significant difference between "class" and "raw data type"?

Kind regards,

Wei Bing

More information about the Gc mailing list