JNI Java From C Memory Leak?

You should free the array1 pointers once you are done with them. What does this function do in reality? From the functionality I understood, you are copying from the java to a c pointer.

What happens next? By calling ReleaseStringUTF, you are notifying the JVM that it isnt being used in native and so can be GCed when required Think I have found the problem. Releasing Code should be something like.

You should free the array1 pointers once you are done with them. What does this function do in reality? From the functionality I understood, you are copying from the java to a c pointer.

What happens next? By calling ReleaseStringUTF, you are notifying the JVM that it isnt being used in native and so can be GCed when required Think I have found the problem. Releasing Code should be something like for (int j=0 ;jGetObjectArrayElement(my_obj,i); Use myString to get the UTFChars, Then call env->ReleaseStringUTFChars(mystring, cstr).

Array1 is being freed after it is being used. Here is how array1 is being freed. The function is a wrapper to a Java method that returns result of an SQL call as an array.

– ShamsR Aug 9 at 17:33 array1 is being freed after it is being used. Here is how array1 is being freed I edited the main post. The function is a wrapper to a Java method that returns result of an SQL call as an array.

What we noticed that if we remove the call of mallocing array1, it still increases JVM heap size so this leads us to think that ReleaseStringUTF is not releasing memory. Would appreciate any help – ShamsR Aug 9 at 17:39 I freeing the array1 like you mentioned, problem still persists, I wonder if it has to do with ReleaseStringUTF not releasing memory or the way we are copying over to c pointer has issues. – ShamsR Aug 10 at 16:50 we were able to solve the problem we had to put jstring myString =env->GetObjectArrayElement(my_obj,i) and then env->ReleaseStringUTFChars(mystring, cstr) and also we had to delete local reference env->DeleteLocalRef(mystring); and it worked and now it is releasing memory just fine.

Thank you very much! – ShamsR Aug 11 at 18:27 upvote/accept any correct answer? – jogabonito Aug 16 at 8:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions