title: Passing NewDirectByteBuffer from C++ to Java (JNI)
body: <p>I have this C++ code:</p>
  
  <pre><code>char *buffer = new char[100];
  
  /*
  *  ...populate this char array with some data...
  */
  
  jobject jbuffer = env-&gt;NewDirectByteBuffer(buffer, 100);
  </code></pre>
  
  <p>Afterwards, I want to pass this DirectByteBuffer that I have created in C++ to Java.</p>
  
  <p>I have 2 questions:</p>
  
  <ol>
  <li>Will <code>env-&gt;NewDirectByteBuffer(buffer, 100)</code> clear out my data in char array buffer? Is this the correct way of doing this?</li>
  <li>When will this buffer be deleted? Should I delete it in C++ sometime afterwards or will Java's GC handle it for me?</li>
  </ol>