When creating NewArray from C++ code in JNI how to release the Array's buffer?












0















I am currently writing a small emulator in C++ using Java as a GUI. In order to achieve this I am making JNI calls from my C++ code passing arrays of data to the GUI application. However due to the shear amount of calls I made in a test run, it has become clear that in my function to pass data a memory leak is occurring.



Before my program has run:
Before my program has run



After my program has run and crashed due to lack of memory:
enter image description here
(Please ignore the CPU usage this program currently uses, I am aware that repeated calls through JNI is inefficient and I have other workarounds to this)



After thorough analysis of whats going on I have concluded that it is not the Java GUI class causing the memory leak but rather the code in the function that passes the data array to the Java GUI:




//java.env is the JNIEnv*
//setDisplay_ is a valid non-null jmethodID at runtime
//displayObject is a valid non-null jobject at runtime

void Display::setDisplay(vector<uint32_t>& a)
{
jint* buffer = new jint[a.size()];
for(int i = 0; i < a.size(); i++)
buffer[i] = (jint)a[i];
jintArray par = java.env->NewIntArray(a.size());
java.env->SetIntArrayRegion(par, 0, a.size(), buffer);
java.env->CallVoidMethod(displayObject, setDisplay_, par);
//java.env->ReleaseIntArrayElements(par, buffer, 0);
delete buffer;
}


The only thing I can see this function causing a memory leak over is the jintArray which I have absolutely no idea what happens to when it goes out of scope so I can only assume is the issue as I release the buffer. However looking at sample code from other people using the JNI with arrays (ex: here) I notice that they never release the Array that they create. While digging through the JNI Documentation I came across the Release<NativeType>ArrayElements Method which I assumed was what I was looking for due to the description:




ReleaseArrayElements Routines
void ReleaseArrayElements(JNIEnv *env,
ArrayType array, NativeType *elems, jint mode);
A family of functions that informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the corresponding GetArrayElements() function. If necessary, this function copies back all changes made to elems to the original array.
The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:




The line that really gave me hope this was what i needed in particular was




The mode argument provides information on how the array buffer should be released




However upon further inspection, im not quite sure this is the method i orrignally thought it was, and this has proved itself in testing as well as it appears to call exit() upon a failure (as JNI is so notorious for) and this failure occurs every time I run it with any of the Modes provided in the documentation.



So my Real Questions is:
When creating New<PrimitiveType>Array from C++ code in JNI how do I release the <PrimitiveType>Array's buffer?










share|improve this question



























    0















    I am currently writing a small emulator in C++ using Java as a GUI. In order to achieve this I am making JNI calls from my C++ code passing arrays of data to the GUI application. However due to the shear amount of calls I made in a test run, it has become clear that in my function to pass data a memory leak is occurring.



    Before my program has run:
    Before my program has run



    After my program has run and crashed due to lack of memory:
    enter image description here
    (Please ignore the CPU usage this program currently uses, I am aware that repeated calls through JNI is inefficient and I have other workarounds to this)



    After thorough analysis of whats going on I have concluded that it is not the Java GUI class causing the memory leak but rather the code in the function that passes the data array to the Java GUI:




    //java.env is the JNIEnv*
    //setDisplay_ is a valid non-null jmethodID at runtime
    //displayObject is a valid non-null jobject at runtime

    void Display::setDisplay(vector<uint32_t>& a)
    {
    jint* buffer = new jint[a.size()];
    for(int i = 0; i < a.size(); i++)
    buffer[i] = (jint)a[i];
    jintArray par = java.env->NewIntArray(a.size());
    java.env->SetIntArrayRegion(par, 0, a.size(), buffer);
    java.env->CallVoidMethod(displayObject, setDisplay_, par);
    //java.env->ReleaseIntArrayElements(par, buffer, 0);
    delete buffer;
    }


    The only thing I can see this function causing a memory leak over is the jintArray which I have absolutely no idea what happens to when it goes out of scope so I can only assume is the issue as I release the buffer. However looking at sample code from other people using the JNI with arrays (ex: here) I notice that they never release the Array that they create. While digging through the JNI Documentation I came across the Release<NativeType>ArrayElements Method which I assumed was what I was looking for due to the description:




    ReleaseArrayElements Routines
    void ReleaseArrayElements(JNIEnv *env,
    ArrayType array, NativeType *elems, jint mode);
    A family of functions that informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the corresponding GetArrayElements() function. If necessary, this function copies back all changes made to elems to the original array.
    The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:




    The line that really gave me hope this was what i needed in particular was




    The mode argument provides information on how the array buffer should be released




    However upon further inspection, im not quite sure this is the method i orrignally thought it was, and this has proved itself in testing as well as it appears to call exit() upon a failure (as JNI is so notorious for) and this failure occurs every time I run it with any of the Modes provided in the documentation.



    So my Real Questions is:
    When creating New<PrimitiveType>Array from C++ code in JNI how do I release the <PrimitiveType>Array's buffer?










    share|improve this question

























      0












      0








      0








      I am currently writing a small emulator in C++ using Java as a GUI. In order to achieve this I am making JNI calls from my C++ code passing arrays of data to the GUI application. However due to the shear amount of calls I made in a test run, it has become clear that in my function to pass data a memory leak is occurring.



      Before my program has run:
      Before my program has run



      After my program has run and crashed due to lack of memory:
      enter image description here
      (Please ignore the CPU usage this program currently uses, I am aware that repeated calls through JNI is inefficient and I have other workarounds to this)



      After thorough analysis of whats going on I have concluded that it is not the Java GUI class causing the memory leak but rather the code in the function that passes the data array to the Java GUI:




      //java.env is the JNIEnv*
      //setDisplay_ is a valid non-null jmethodID at runtime
      //displayObject is a valid non-null jobject at runtime

      void Display::setDisplay(vector<uint32_t>& a)
      {
      jint* buffer = new jint[a.size()];
      for(int i = 0; i < a.size(); i++)
      buffer[i] = (jint)a[i];
      jintArray par = java.env->NewIntArray(a.size());
      java.env->SetIntArrayRegion(par, 0, a.size(), buffer);
      java.env->CallVoidMethod(displayObject, setDisplay_, par);
      //java.env->ReleaseIntArrayElements(par, buffer, 0);
      delete buffer;
      }


      The only thing I can see this function causing a memory leak over is the jintArray which I have absolutely no idea what happens to when it goes out of scope so I can only assume is the issue as I release the buffer. However looking at sample code from other people using the JNI with arrays (ex: here) I notice that they never release the Array that they create. While digging through the JNI Documentation I came across the Release<NativeType>ArrayElements Method which I assumed was what I was looking for due to the description:




      ReleaseArrayElements Routines
      void ReleaseArrayElements(JNIEnv *env,
      ArrayType array, NativeType *elems, jint mode);
      A family of functions that informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the corresponding GetArrayElements() function. If necessary, this function copies back all changes made to elems to the original array.
      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:




      The line that really gave me hope this was what i needed in particular was




      The mode argument provides information on how the array buffer should be released




      However upon further inspection, im not quite sure this is the method i orrignally thought it was, and this has proved itself in testing as well as it appears to call exit() upon a failure (as JNI is so notorious for) and this failure occurs every time I run it with any of the Modes provided in the documentation.



      So my Real Questions is:
      When creating New<PrimitiveType>Array from C++ code in JNI how do I release the <PrimitiveType>Array's buffer?










      share|improve this question














      I am currently writing a small emulator in C++ using Java as a GUI. In order to achieve this I am making JNI calls from my C++ code passing arrays of data to the GUI application. However due to the shear amount of calls I made in a test run, it has become clear that in my function to pass data a memory leak is occurring.



      Before my program has run:
      Before my program has run



      After my program has run and crashed due to lack of memory:
      enter image description here
      (Please ignore the CPU usage this program currently uses, I am aware that repeated calls through JNI is inefficient and I have other workarounds to this)



      After thorough analysis of whats going on I have concluded that it is not the Java GUI class causing the memory leak but rather the code in the function that passes the data array to the Java GUI:




      //java.env is the JNIEnv*
      //setDisplay_ is a valid non-null jmethodID at runtime
      //displayObject is a valid non-null jobject at runtime

      void Display::setDisplay(vector<uint32_t>& a)
      {
      jint* buffer = new jint[a.size()];
      for(int i = 0; i < a.size(); i++)
      buffer[i] = (jint)a[i];
      jintArray par = java.env->NewIntArray(a.size());
      java.env->SetIntArrayRegion(par, 0, a.size(), buffer);
      java.env->CallVoidMethod(displayObject, setDisplay_, par);
      //java.env->ReleaseIntArrayElements(par, buffer, 0);
      delete buffer;
      }


      The only thing I can see this function causing a memory leak over is the jintArray which I have absolutely no idea what happens to when it goes out of scope so I can only assume is the issue as I release the buffer. However looking at sample code from other people using the JNI with arrays (ex: here) I notice that they never release the Array that they create. While digging through the JNI Documentation I came across the Release<NativeType>ArrayElements Method which I assumed was what I was looking for due to the description:




      ReleaseArrayElements Routines
      void ReleaseArrayElements(JNIEnv *env,
      ArrayType array, NativeType *elems, jint mode);
      A family of functions that informs the VM that the native code no longer needs access to elems. The elems argument is a pointer derived from array using the corresponding GetArrayElements() function. If necessary, this function copies back all changes made to elems to the original array.
      The mode argument provides information on how the array buffer should be released. mode has no effect if elems is not a copy of the elements in array. Otherwise, mode has the following impact, as shown in the following table:




      The line that really gave me hope this was what i needed in particular was




      The mode argument provides information on how the array buffer should be released




      However upon further inspection, im not quite sure this is the method i orrignally thought it was, and this has proved itself in testing as well as it appears to call exit() upon a failure (as JNI is so notorious for) and this failure occurs every time I run it with any of the Modes provided in the documentation.



      So my Real Questions is:
      When creating New<PrimitiveType>Array from C++ code in JNI how do I release the <PrimitiveType>Array's buffer?







      java c++ jni jnienv






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 19 at 6:30









      James OswaldJames Oswald

      1611512




      1611512
























          1 Answer
          1






          active

          oldest

          votes


















          2














          After a bit more digging I came upon Do I need to call ReleaseIntArrayElements on an array created with NewIntArray? with a short answer from @gerbit :




          You have to release only reference:



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



          So apparently when using the JNI in the direction of Java calling C++, you dont need to clean up your <PrimitiveType>Array's as java handles this for you. However when calling from the direction of C++ to Java, You need to call DeleteLocalRef() in order to prevent memory leaks.






          share|improve this answer



















          • 1





            If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

            – Michael
            Jan 19 at 12:12






          • 1





            @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

            – Wheezil
            Jan 19 at 16:41






          • 1





            @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

            – Michael
            Jan 19 at 17:05






          • 1





            Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

            – Wheezil
            Jan 20 at 16:39











          • Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

            – James Oswald
            Jan 21 at 14:27











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264656%2fwhen-creating-newprimitivetypearray-from-c-code-in-jni-how-to-release-the-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          After a bit more digging I came upon Do I need to call ReleaseIntArrayElements on an array created with NewIntArray? with a short answer from @gerbit :




          You have to release only reference:



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



          So apparently when using the JNI in the direction of Java calling C++, you dont need to clean up your <PrimitiveType>Array's as java handles this for you. However when calling from the direction of C++ to Java, You need to call DeleteLocalRef() in order to prevent memory leaks.






          share|improve this answer



















          • 1





            If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

            – Michael
            Jan 19 at 12:12






          • 1





            @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

            – Wheezil
            Jan 19 at 16:41






          • 1





            @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

            – Michael
            Jan 19 at 17:05






          • 1





            Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

            – Wheezil
            Jan 20 at 16:39











          • Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

            – James Oswald
            Jan 21 at 14:27
















          2














          After a bit more digging I came upon Do I need to call ReleaseIntArrayElements on an array created with NewIntArray? with a short answer from @gerbit :




          You have to release only reference:



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



          So apparently when using the JNI in the direction of Java calling C++, you dont need to clean up your <PrimitiveType>Array's as java handles this for you. However when calling from the direction of C++ to Java, You need to call DeleteLocalRef() in order to prevent memory leaks.






          share|improve this answer



















          • 1





            If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

            – Michael
            Jan 19 at 12:12






          • 1





            @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

            – Wheezil
            Jan 19 at 16:41






          • 1





            @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

            – Michael
            Jan 19 at 17:05






          • 1





            Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

            – Wheezil
            Jan 20 at 16:39











          • Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

            – James Oswald
            Jan 21 at 14:27














          2












          2








          2







          After a bit more digging I came upon Do I need to call ReleaseIntArrayElements on an array created with NewIntArray? with a short answer from @gerbit :




          You have to release only reference:



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



          So apparently when using the JNI in the direction of Java calling C++, you dont need to clean up your <PrimitiveType>Array's as java handles this for you. However when calling from the direction of C++ to Java, You need to call DeleteLocalRef() in order to prevent memory leaks.






          share|improve this answer













          After a bit more digging I came upon Do I need to call ReleaseIntArrayElements on an array created with NewIntArray? with a short answer from @gerbit :




          You have to release only reference:



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



          So apparently when using the JNI in the direction of Java calling C++, you dont need to clean up your <PrimitiveType>Array's as java handles this for you. However when calling from the direction of C++ to Java, You need to call DeleteLocalRef() in order to prevent memory leaks.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 19 at 7:28









          James OswaldJames Oswald

          1611512




          1611512








          • 1





            If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

            – Michael
            Jan 19 at 12:12






          • 1





            @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

            – Wheezil
            Jan 19 at 16:41






          • 1





            @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

            – Michael
            Jan 19 at 17:05






          • 1





            Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

            – Wheezil
            Jan 20 at 16:39











          • Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

            – James Oswald
            Jan 21 at 14:27














          • 1





            If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

            – Michael
            Jan 19 at 12:12






          • 1





            @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

            – Wheezil
            Jan 19 at 16:41






          • 1





            @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

            – Michael
            Jan 19 at 17:05






          • 1





            Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

            – Wheezil
            Jan 20 at 16:39











          • Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

            – James Oswald
            Jan 21 at 14:27








          1




          1





          If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

          – Michael
          Jan 19 at 12:12





          If the call originates from Java and you'll return back to Java, then the local references that you have created will be automatically deleted when you return back to Java. If you're creating a lot of local references (e.g. in a loop) then it's still a good idea to explicitly delete them as soon as they're no longer needed. In the case of a purely native thread, the references will be deleted for you when you detach the thread with DetachCurrentThread. But depending on the lifetime of the thread and how frequently it will create new local references, it may be best to delete them yourself.

          – Michael
          Jan 19 at 12:12




          1




          1





          @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

          – Wheezil
          Jan 19 at 16:41





          @Michael that is not quite true. The local references are only cleaned up when the C++ thread returns to the Java frame from which it was called. If the C++ thread was not called from Java or never returns to Java, the local refs will accumulate. It is not good enough to make a JNI call, which if you think about it makes sense -- you would not want your local refs to become invalid just because you make a call.

          – Wheezil
          Jan 19 at 16:41




          1




          1





          @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

          – Michael
          Jan 19 at 17:05





          @Wheezil I don't see how that differs from what I wrote ("the local references that you have created will be automatically deleted when you return back to Java"). Except that I also mentioned the case of a purely native thread that calls DetachCurrentThread.

          – Michael
          Jan 19 at 17:05




          1




          1





          Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

          – Wheezil
          Jan 20 at 16:39





          Righto. I should have read more closely. Between the two of us, I think we've nailed it :-)

          – Wheezil
          Jan 20 at 16:39













          Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

          – James Oswald
          Jan 21 at 14:27





          Thanks both of you, ill edit my post sometime to incorporate your comments sometime and hopefully this will help people with the same issue.

          – James Oswald
          Jan 21 at 14:27


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54264656%2fwhen-creating-newprimitivetypearray-from-c-code-in-jni-how-to-release-the-p%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Homophylophilia

          Updating UILabel text programmatically using a function

          Cloud Functions - OpenCV Videocapture Read method fails for larger files from cloud storage