This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: CNI and garbage collection


>>>>> "BM" == Bryce McKinlay <bryce@waitaki.otago.ac.nz> writes:

BM> So how to keep a pointer, associated with a given class or object,
BM> to your native object? One solution is to declare a field (in
BM> Java) of the type gnu.gcj.RawData. This class is treated specially
BM> by the garbage collector, and can be used for storing a pointer to
BM> some native, non-Java object. RawData fields will not be marked by
BM> the GC, so you need to dealocate them explicitly (perhaps from a
BM> finalizer).

Works like a charm.  Thanks very much. 

MD> But what about the C++ objects inside of the Java object?  Is
MD> there a special way to allocate them?

>>>>> "JS" == Jeff Sturm <jsturm@one-point.com> writes:

JS> You could try to override the "new" operator to place C++
JS> objects where they will be traced.  But that exposes details of the
JS> collector implementation, and could have other pitfalls when done
JS> together with libgcj.  See boehm-gc/include/gc_cpp.h for more info.

Cool, thanks for the pointer.  (And to both of you for pointing out that
Boehm GC doesn't move things!)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]