title: Android NDK overflows dalvik JNI local reference table
body: <p>I have the following problem, from c++ I send huge string[] to java. huge = at most 20 rows; 
  I am doing the following </p>
  
  <pre><code>jint jtype = 2;
  jstring emptyString = env-&gt;NewStringUTF("");
  jobjectArray data = (jobjectArray)env-&gt;NewObjectArray(7, env-&gt;FindClass("java/lang/String"), emptyString);
  
  env-&gt;SetObjectArrayElement( data,0,env-&gt;NewStringUTF(item-&gt;get_id().c_str());
  env-&gt;SetObjectArrayElement( data,1,env-&gt;NewStringUTF(item-&gt;get_number().c_str());
  env-&gt;SetObjectArrayElement( data,2,env-&gt;NewStringUTF(item-&gt;get_fullname().c_str());
  env-&gt;SetObjectArrayElement( data,3,env-&gt;NewStringUTF(item-&gt;get_mf().c_str());
  env-&gt;SetObjectArrayElement( data,4,env-&gt;NewStringUTF(item-&gt;get_dob().c_str());
  env-&gt;CallVoidMethod(dao, jsaveItem, data, jtype);
  int i;
  for (i = 0; i &lt; 5; ++i) {
     jstring string = (jstring) env-&gt;GetObjectArrayElement(data, i);
     env-&gt;DeleteLocalRef(string);
  }
  env-&gt;DeleteLocalRef(emptyString);
  env-&gt;DeleteLocalRef(data);
  env-&gt;DeleteLocalRef(dao);
  </code></pre>
  
  <p>this is happening in a loop so I am doing it for every object I want to save in the database, so as you can imagine, it happends lots of times.</p>
  
  <p>So I am considerate of the VM and delete the local refs of every string I create, but still I get  : </p>
  
  <pre><code> ReferenceTable overflow (max=512)
  Last 10 entries in JNI local reference table:
    502: 0x40552880 cls=Ljava/lang/String; (28 bytes)
    503: 0x405528b8 cls=Ljava/lang/String; (28 bytes)
    504: 0x4051f8d0 cls=Ljava/lang/Class; 'Lcom/project/storage/userdata/DataDao;' (212 bytes)
    505: 0x4052eb38 cls=Lcom/project/storage/userdata/DataDao; (12 bytes)
    506: 0x4051f8d0 cls=Ljava/lang/Class; 'Lcom/project/storage/userdata/DataDao;' (212 bytes)
    507: 0x4052eb38 cls=Lcom/project/storage/userdata/DataDao; (12 bytes)
    508: 0x4051f8d0 cls=Ljava/lang/Class; 'Lcom/project/storage/userdata/DataDao;' (212 bytes)
    509: 0x4052eb38 cls=Lcom/project/storage/userdata/DataDao; (12 bytes)
    510: 0x4051f8d0 cls=Ljava/lang/Class; 'Lcom/project/storage/userdata/DataDao;' (212 bytes)
    511: 0x4052eb38 cls=Lcom/project/storage/userdata/DataDao; (12 bytes)
  JNI local reference table summary (512 entries):
     58 of Ljava/lang/Class; 212B (1 unique)
      1 of Ljava/lang/Class; 236B
     25 of Ljava/lang/Class; 284B (1 unique)
      1 of Ljava/lang/Class; 572B
    392 of Ljava/lang/String; 28B (392 unique)
      1 of Ljava/lang/String; 36B
      1 of [Ljava/lang/String; 28B
      2 of [Ljava/lang/String; 92B (2 unique)
     31 of Lcom/project/storage/userdata/DataDao; 12B (1 unique)
  Memory held directly by tracked refs is 12540 bytes
  </code></pre>
  
  <p>Any ideas as to why the overflow is happening?
  what am I doing wrong?</p>