I am using JNI to call some back end logic. Everything is working fine except a memory leak which is crashing the JVM after repeated runs. In one function, I am creating and returning a large "jobject" to Java code from JNI. This object is not being deleted after the return from the JNI call. The JVM is being crashed when the code tries to create the same object in the next run as the PermGen Object Space is utilized 99%. The JVM is being crashed in the GCTask thread as shown from the crash dump log files.
Here is the Memory info from the crash dump log file:
PSYoungGen total 196224K, used 78894K [0x0000002ad4070000, 0x0000002ae5e30000, 0x0000002ae95c0000)
eden space 195840K, 40% used [0x0000002ad4070000,0x0000002ad8d23870,0x0000002adffb0000)
from space 384K, 91% used [0x0000002ae04a0000,0x0000002ae04f8040,0x0000002ae0500000)
to space 48384K, 0% used [0x0000002ae2ef0000,0x0000002ae2ef0000,0x0000002ae5e30000)
PSOldGen total 524288K, used 124951K [0x0000002aa95c0000, 0x0000002ac95c0000, 0x0000002ad4070000)
object space 524288K, 23% used [0x0000002aa95c0000,0x0000002ab0fc5c80,0x0000002ac95c0000)
PSPermGen total 106688K, used 106538K [0x0000002a995c0000, 0x0000002a9fdf0000, 0x0000002aa95c0000)
object space 106688K, 99% used [0x0000002a995c0000,0x0000002a9fdca950,0x0000002a9fdf0000)
Is there any way that I can forcibly delete that local reference object manually as GC is not deleting it?
For each run I have to check if the object is there in the environment, and if if yes, I need to delete it. Is there any way that i can check if a particular object is present in the JNI env ?
How can I see all the references to that object which are blocking the object from being garbage-collected?