Re: Java objects obtained by c++: are they garbage collected?
Glenn Chambers <[email protected]>
| Newsgroups | gmane.comp.gcc.java.devel |
|---|---|
| Message-ID | <1255723172.32229.2.camel@localhost> |
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.