wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Garbage collection of native objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Garbage collection of native objects" Watch "Garbage collection of native objects" New topic
Author

Garbage collection of native objects

Jim Bedenbaugh
Ranch Hand

Joined: Nov 09, 2001
Posts: 171
I think I know the answer to this, but I want an informed opinion.
I've looked through the JLS and API, and as best I can tell, objects created by a native call (meaning objects that might be created by a C++ program that was called from a Java app) are not garbage collected by the JVM.
Is this a correct assertion?


Regards,
Jim
SCJP, SCJD, SCWCD, SCEA Part I
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
From Reference Objects and Garbage Collection:

If you use the Java Native Interface (JNI) API to make C calls, the garbage collector might see something in memory created by the C code that looks like a pointer, but is actually garbage. In this case, the memory is not garbage collected because the Java VM is conservative and does not reclaim memory that looks like it could be allocated to a pointer.

[ April 15, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage collection of native objects