我從java複製了一個多維數組,但我在使用它之後釋放內存時遇到了一些問題。無法添加到JNI固定陣列參考表(1024個條目)
我所做的是:
jfieldID h_valID = (*env)->GetFieldID(env, h_cls, "val", "[[I");
jobjectArray h_val_obj = (*env)->GetObjectField(env, h, h_valID);
int h_val_local[xdim][ydim];
for(i=0; i<xdim; i++)
{
h_val_one_dim = (jintArray) (*env)->GetObjectArrayElement(env, h_val_obj, i);
h_val_elem = (*env)->GetIntArrayElements(env, h_val_one_dim, 0);
for(j=0; j<ydim; j++)
{
h_val_local[i][j] = h_val_elem[j];
}
(*env)->ReleaseIntArrayElements(env, h_val_one_dim, h_val_elem, 0);
(*env)->DeleteLocalRef(env, h_val_one_dim);
}
(*env)->DeleteLocalRef(env, h_val_obj);
我對那個方法4個陣列,所有的參數,我得到的指針,然後使用它後釋放。
int *x = (*env)->GetIntArrayElements(env,x_p,0);
int *y = (*env)->GetIntArrayElements(env,y_p,0);
int *v = (*env)->GetIntArrayElements(env,v_p,0);
int *w = (*env)->GetIntArrayElements(env,w_p,0);
...
(*env)->ReleaseIntArrayElements(env, x_p, x, 0);
(*env)->ReleaseIntArrayElements(env, y_p, y, 0);
(*env)->ReleaseIntArrayElements(env, v_p, v, 0);
(*env)->ReleaseIntArrayElements(env, w_p, w, 0);
對於更大的文件,我在參考表中獲取溢出。我忘了自由或我該如何解決這個問題?
日誌:
10-02 14:18:58.885:W/dalvikvm(23598):ReferenceTable溢出(最大值= 1024)
10-02 14:18:58.885:W/dalvikvm(23598):在被釘扎JNI陣列基準表最後10個條目:
10-02 14:18:58.885:W/dalvikvm(23598):1014:0x46109fe8 CLS = [I(24個字節)
10-02 14:18:58.885:W/dalvikvm(23598):1015:0x4610a008 cls = [I(24字節)
10-02 14:18:58.885:W/dalvikvm(23598):1016:0x46109fa8 CLS = [I(24個字節)
10-02 14:18:58.885:W/dalvikvm(23598) :1017:0x46109fc8 CLS = [I(24個字節)
10-02 14:18:58.885:W/dalvikvm(23598):1018:0x46109fe8 CLS = [I(24個字節)
10-02 14:18:58.885:W/dalvikvm(23598):1019:0x4610a008 cls = [I(24字節)
10-02 14:18:58.885:W/dalvikvm(23598):1020:0x46109fa8 cls =我(24字節)
10-02 14:18:58.885:W/dalvikvm(23598):1021:0x46109fc8 CLS = [I(24個字節)
10-02 14:18:58.885:W/dalvikvm(23598): 1022:0x46109fe8 CLS = [I(24個字節)
10-02 14:18:58.885:W/dalvikvm(23598):1023:0x4610a008 CLS = [I(24個字節)
10-02 14 :18:58.885:W/dalvikvm(23598):JNI固定陣列參考表摘要(1024項):
10-02 14:18:58.885:W/dalvikvm(23598)獨特)
10-02 14:18:58.885:W/dalvikvm(23598):由被跟蹤的參直接持有存儲器是96個字節
10-02 14時十八分58秒。885:E/dalvikvm(23598):未能加入JNI固定數組引用表(1024項)
THX
感謝您的回答,但我發現問題不在我上面發佈的部分。 – Deadlock