title: Failed adding to JNI pinned array ref table (1024 entries)
body: <p>I copied a multidimensional array from java, but i am having some problems to free the memory after using it.</p>
  <p>what i did is:</p>
  <pre><code>jfieldID h_valID = (*env)-&gt;GetFieldID(env, h_cls, &quot;val&quot;, &quot;[[I&quot;);
  jobjectArray h_val_obj = (*env)-&gt;GetObjectField(env, h, h_valID);
  int h_val_local[xdim][ydim];
  for(i=0; i&lt;xdim; i++)
  {
      h_val_one_dim = (jintArray) (*env)-&gt;GetObjectArrayElement(env, h_val_obj, i);
      h_val_elem = (*env)-&gt;GetIntArrayElements(env, h_val_one_dim, 0);
      for(j=0; j&lt;ydim; j++)
      {
          h_val_local[i][j] = h_val_elem[j];
      }
      (*env)-&gt;ReleaseIntArrayElements(env, h_val_one_dim, h_val_elem, 0);
      (*env)-&gt;DeleteLocalRef(env, h_val_one_dim);
  }
  (*env)-&gt;DeleteLocalRef(env, h_val_obj);
  </code></pre>
  <p>I have 4 more arrays on that method, all on the parameters, i'm getting the pointer then releasing after using it.</p>
  <pre><code>int *x = (*env)-&gt;GetIntArrayElements(env,x_p,0);
  int *y = (*env)-&gt;GetIntArrayElements(env,y_p,0);
  int *v = (*env)-&gt;GetIntArrayElements(env,v_p,0);
  int *w = (*env)-&gt;GetIntArrayElements(env,w_p,0);
  </code></pre>
  <p>...</p>
  <pre><code>(*env)-&gt;ReleaseIntArrayElements(env, x_p, x, 0);
  (*env)-&gt;ReleaseIntArrayElements(env, y_p, y, 0);
  (*env)-&gt;ReleaseIntArrayElements(env, v_p, v, 0);
  (*env)-&gt;ReleaseIntArrayElements(env, w_p, w, 0);
  </code></pre>
  <p>For bigger files, i'm getting overflow on the reference table. What i'm forgetting to free or how do i fix this?</p>
  <p>Log:</p>
  <blockquote>
  <p>10-02 14:18:58.885: W/dalvikvm(23598): ReferenceTable overflow (max=1024)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598): Last 10 entries in JNI pinned array reference table:</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1014: 0x46109fe8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1015: 0x4610a008 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1016: 0x46109fa8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1017: 0x46109fc8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1018: 0x46109fe8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1019: 0x4610a008 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1020: 0x46109fa8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1021: 0x46109fc8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1022: 0x46109fe8 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1023: 0x4610a008 cls=[I (24 bytes)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598): JNI pinned array reference table summary (1024 entries):</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598):  1024 of [I 24B (4 unique)</p>
  <p>10-02 14:18:58.885: W/dalvikvm(23598): Memory held directly by tracked refs is 96 bytes</p>
  <p>10-02 14:18:58.885: E/dalvikvm(23598): Failed adding to JNI pinned array ref table (1024 entries)</p>
  </blockquote>
  <p>thx</p>