Java – do I need to call releaseintarrayelements on an array created using newintarray?

I have a local method to do some work on bitmaps Inside the method, I obtain image data through a method call, which writes the data into the jintarray parameter created using newintarray:

jintArray pixels = env-> NewIntArray(width * height);

I don't need to return this array to the calling java code - it's only used for processing in this method Do I need to call releaseintarrayelements on pixels? If so, what do I pass the elems parameter because I don't need to copy it back to the Java array?

Void (jnical * releaseintarrayelements) (jnienv * Env, jintarray array, jint * elements, jint mode);

Solution

You don't need to do anything It is a local reference that will be cleared when your JNI method exits As Edward Thompson mentioned, releaseintarrayelements() is the opposite of getintarrayelements() It has no other functions

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>