0 Replies Latest reply on Jul 15, 2008 3:05 PM by 843810

    Using JVMPI to find JNI memory leaks?

      I have a C application which loads a JVM via JNI to run Java code. I am experiencing what I am assuming is a leak. After running the same test case itteratively the JVM throws an OOM error and hangs. It produces a heap dump but not a thread dump. it starts to generate it but never completes it due to the hang. As far as I can see I am deleting all local/global references and releasing String objects. I've tried NUMEROUS tools (this needs to be passive) as I can only obtain a heap dump and cannot connect remotely or locally to the JVM which is running in another environment. I believe objects are pinned in the heap. There is a leak, tuning is not going to solve this issue.

      This is a 1.4.2 JVM so I am forced to use JVMPI rather than JVMTI, I cannot rebuild and switch out the JVM. One thing I have tried to do is use JVMPI to track Global ALLOC and FREE events. I store the ref_id and print them to stdout after I run the test case once. It does appear that four global refs are allocated but not FREED. I really don't believe this is happening from our JNI code but to verify I have searched for the ref_id's from these four objects in a corresponding heap dump taken from the test case run. None of the ref_id's are in the heap dump. I am going to cross post part of this to the tools forum.

      Shouldn't the leftover ALLOC ref_id's which don't have corresponding FREE events show up in the Java Heap I am searching though post-mortem?