I’m porting a lot of math. I’m using over to c++ from java and seeing a great performance boost from doing so but I cant figure out what jni function to use in order to get rid of variables that I don’t need anymore. For instance I know that when your jni method comes to it end and you’ve been using jfloatArray you call :
env->ReleaseFloatArrayElements(vec,in,0);
And that would destroy the array and free up memory. I’d like to be able to do the same with single primitives that aren’t array types if possible but I’ve looked through the oracle and sun docs and there is no methods to do such a thing……should I just use the default way to destroy objects using c++ or is there a safe sure fire way to do such a thing.
There’s nothing necessary. You only have to clean up in cases where the
JNI interface may have allocated memory or other resources. Basic
types, like
jfloat, are typedef’s for basic C++ types (usually,float), and are passed around by copy; when you declare ajfloat,it’s just a floating point type on the stack, and disappears when you
leave its scope. The types you have to clean up will normally be
pointers; the clean-up functions are there to free up the memory the
pointer points to.