title: How to Release jstring that is sent from Native Code back to Java?
body: <p>I have the following native routine:</p>
  
  <pre><code>void sendMessage(const char* text)
  {
      JNIEnv* env;
  
      if(!_jvm)
          return;
  
      _jvm-&gt;AttachCurrentThread(&amp;env, NULL);
  
      if(!_nativesCls)
          _nativesCls = env-&gt;FindClass("com/foo/BaseLib");
      if(_nativesCls == 0)
              return;
  
      jstring message = env-&gt;NewStringUTF(text);
      if(!_sendStr)
          _sendStr = env-&gt;GetStaticMethodID(_nativesCls, "onMessage", "(Ljava/lang/String;)V");
      if(_sendStr)
          env-&gt;CallStaticVoidMethod(_nativesCls, _sendStr, message);
      //env-&gt;ReleaseStringUTFChars(message, text); // &lt;----- * NOT WORKING
  }
  </code></pre>
  
  <p>If I run this as is, it works fine up until memory fills up and I receive:</p>
  
  <blockquote>
    <p>ReferenceTable overflow (max=512)</p>
  </blockquote>
  
  <p>I thought adding the commented line above would fix the issue but it just causes the app to bomb out at that point.</p>
  
  <p>Any suggestions?</p>