Java objects obtained by c++: are they garbage collected?

Glenn Chambers gchamber@bright.net
Fri Oct 16 19:59:00 GMT 2009


On Fri, 2009-10-16 at 12:17 -0700, Yuri wrote:
> David Daney wrote:

> > If you use the CNI facilities to start the runtime and do the calling, 
> > everything should just work (including garbage collection).
> 
> I initialize the runtime using CNI and call methods using dlsym + call 
> of that symbol.

I saved a bunch of previous messages on the subject in my e-mail folder.

Something that may be relevant to your situation:

Andre Haley wrote:

> I think a bit more clarification is required.
> 
> If you get a reference to a Java object as a result of a function
> call, you must store that reference somewhere that is reachable by the
> collector or that object will be collected.  The collector scans all
> fields of all objects, so something like
> 
>     MyClass::foo = objectRef;
> 
> is sufficient.  Storing the reference in an object in the C++ heap
> will *not* do.





More information about the Java mailing list