* Java objects obtained by c++: are they garbage collected?
@ 2009-10-16 18:19 Yuri
2009-10-16 18:35 ` David Daney
0 siblings, 1 reply; 4+ messages in thread
From: Yuri @ 2009-10-16 18:19 UTC (permalink / raw)
To: java
I compiled several Java classes into a shared library and call it's
methods from C++.
Some of these methods return Java objects.
I wonder do I have to do anything special about them in order for them
to get garbage collected?
Yuri
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Java objects obtained by c++: are they garbage collected?
2009-10-16 18:19 Java objects obtained by c++: are they garbage collected? Yuri
@ 2009-10-16 18:35 ` David Daney
2009-10-16 19:17 ` Yuri
0 siblings, 1 reply; 4+ messages in thread
From: David Daney @ 2009-10-16 18:35 UTC (permalink / raw)
To: yuri; +Cc: java
Yuri wrote:
> I compiled several Java classes into a shared library and call it's
> methods from C++.
> Some of these methods return Java objects.
>
> I wonder do I have to do anything special about them in order for them
> to get garbage collected?
>
If you use the CNI facilities to start the runtime and do the calling,
everything should just work (including garbage collection).
David Daney
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Java objects obtained by c++: are they garbage collected?
2009-10-16 18:35 ` David Daney
@ 2009-10-16 19:17 ` Yuri
2009-10-16 19:59 ` Glenn Chambers
0 siblings, 1 reply; 4+ messages in thread
From: Yuri @ 2009-10-16 19:17 UTC (permalink / raw)
To: David Daney; +Cc: java
David Daney wrote:
> Yuri wrote:
>> I compiled several Java classes into a shared library and call it's
>> methods from C++.
>> Some of these methods return Java objects.
>>
>> I wonder do I have to do anything special about them in order for
>> them to get garbage collected?
>>
>
> 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.
Yuri
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Java objects obtained by c++: are they garbage collected?
2009-10-16 19:17 ` Yuri
@ 2009-10-16 19:59 ` Glenn Chambers
0 siblings, 0 replies; 4+ messages in thread
From: Glenn Chambers @ 2009-10-16 19:59 UTC (permalink / raw)
To: yuri; +Cc: David Daney, java
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.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-10-16 19:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-16 18:19 Java objects obtained by c++: are they garbage collected? Yuri
2009-10-16 18:35 ` David Daney
2009-10-16 19:17 ` Yuri
2009-10-16 19:59 ` Glenn Chambers
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).