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]
Other format: [Raw text]

Re: Using CNI to call compiled java from C++


On Oct 22, 2003, at 8:04 PM, Stéphane MILLET wrote:

I agree with your answer but don't understand how the collector decides that the object isn't reachable anymore. The Java object is allocated and used in the C++ side of the program, so... Is it declared unreachable as soon as you exit the current function like a local variable ? or is there a function that makes an object reclaimable ?

The object is unreachable once it can no longer be accessed from the stack or static roots of your program. So, given that a reference to this object is stored in a local (stack) variable, and assuming another reference to it isn't stored somewhere, it becomes unreachable once you exit the current function or explicitly set that variable to NULL or to another object.


In my program, at the moment the finalizers of those types of objects are never called.

Then that would be a bug - do you have a test case? But, note that unlike C++ destructors, finalizers in Java are asynchronous and do not run at predictable times. Finalizers won't be run until after a GC cycle has completed, and the GC won't run unless you allocate enough objects to trigger it.


Regards

Bryce.


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