In JNI I'm constructing a large array by calling SetObjectArrayElement()
to insert a java object created locally in the JNI
code.
My question is, after inserting the object into the array using SetObjectArrayElement()
, does the array store a reference such that I can use DeleteLocalRef to free the local reference to the object that is inserted?
Yes.
The jobjectArray points to an array of references.
When you set a member of that array to a local reference, you've made a second reference to the object. If you delete the local reference, the reference in the array remains. The garbage collector will not dispose of the actual object until there are no remaining reachable references.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With