aspose file tools*
The moose likes Java in General and the fly likes Garbage Collection in JNI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Garbage Collection in JNI" Watch "Garbage Collection in JNI" New topic
Author

Garbage Collection in JNI

Dhamodharan Krishnan
Greenhorn

Joined: Nov 07, 2001
Posts: 23
Hi,
I need to do garbage collection in JNI. Please clarify me the following points.
I assume these concepts are correct upto the knowledge that I had gained from the books that I read.
I am going to implement in our project all these concepts. So, I thought of getting opinion from you people.
Please criticize.
I do C to Java communication ( With C creating the JVM and executes Java methods )
Point No:1
-----------
I do know that global reference will keep the object from being garbage collected across many JNI calls. i.e. JVM wont gc this object unless we explicitly delete the global reference.
Please validate this.
Point No:2
-----------
An object is created as a local reference.
Do I need delete it in order to allow gcollector to swallow this object.
Point No:3
----------
During core dump, can I give the function call to do safe shutdown, in order to avoid dangerous loss of data. i.e. like closing certain
Connection.
Point No:4
-----------
The methodIDs, fieldIDs are not changed on a particular machine unless I do change anything in the Java side.
Point No:5
-----------
Any string obtained using GetStringUTFChars() has to be followed by ReleaseStringUTF().
Please add any more points.
My C program is going to run like a Demon.
Can I use threading in Java.
Or it is better to implement threads in C?
Please suggest any online material for JNI that can be downloadable.

Dhamo
dhamo_dharan@indiainfo.com


Dhamodharan Krishnan,<br />Sun Microsystems, Bangalore<br />Direct : 91-80-4184 7247<br />Cell : 91-99 80 147 600
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
hi:
please check out:
JVM properties;
Reference Objects and Garbage Collection;
Dhamodharan Krishnan
Greenhorn

Joined: Nov 07, 2001
Posts: 23
Thanks Don,
Let me try to free the memory allocated in C and try it out.
Thanks for the valuable links.
I think we can make a search in sun site too.
Dhamo.
John Lee
Ranch Hand

Joined: Aug 05, 2001
Posts: 2545
you are welcome!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Garbage Collection in JNI
 
Similar Threads
garbage collection
one question about gc?
Mock exam questions section 3
doubt on garbage collection
Can I delete an object explicitly in Java?