在android中调用jni,出现ReferenceTable overflow (max=1024)
小弟最近入手android的jni,大体是做个车牌识别的功能,但在java层循环调用jni识别算法时出现了ReferenceTable overflow (max=1024)这个错误,程序整个就退出了,到网上查了是说没有释放资源,但也不是这么回事,小弟无计可施了,恳请各位帮忙,不胜感激!代码&日志如下,
代码:
extern "C" JNIEXPORT jdouble JNICALL Java_com_opencv_lpr_LibLPR_LPRprocess(
JNIEnv* env, jobject obj, jintArray imgbuf, jint w, jint h, jintArray scanArea, jlongArray BPaddress, jintArray result)
{
jint *cimgbuf = env->GetIntArrayElements(imgbuf, 0);
jint *cscanArea = env->GetIntArrayElements(scanArea, 0);
jlong *cBPaddress = env->GetLongArrayElements(BPaddress, 0);
jint *cresult = env->GetIntArrayElements(result, 0);
...
env->ReleaseIntArrayElements(result, cresult, 0);
env->ReleaseLongArrayElements(BPaddress, cBPaddress, 0);
env->ReleaseIntArrayElements(scanArea, cscanArea, 0);
env->ReleaseIntArrayElements(imgbuf, cimgbuf, 0);
return ...
}
日志如下:
05-02 14:50:16.815: W/dalvikvm(8147): ReferenceTable overflow (max=1024)
05-02 14:50:16.815: W/dalvikvm(8147): JNI pinned array reference table (0x68088300) dump:
05-02 14:50:16.815: W/dalvikvm(8147): Last 10 entries (of 1024):
05-02 14:50:16.815: W/dalvikvm(8147): 1023: 0x4276a740 int[] (10 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1022: 0x4276a6e8 long[] (8 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1021: 0x42752700 int[] (4 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1020: 0x477cf448 int[] (72000 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1019: 0x4276a740 int[] (10 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1018: 0x4276a6e8 long[] (8 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1017: 0x42750118 int[] (4 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1016: 0x47788f30 int[] (72000 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1015: 0x4276a740 int[] (10 elements)
05-02 14:50:16.815: W/dalvikvm(8147): 1014: 0x4276a6e8 long[] (8 elements)
05-02 14:50:16.815: W/dalvikvm(8147): Summary:
05-02 14:50:16.815: W/dalvikvm(8147): 256 of int[] (4 elements) (256 unique instances)
05-02 14:50:16.815: W/dalvikvm(8147): 256 of int[] (10 elements) (1 unique instances)
05-02 14:50:16.815: W/dalvikvm(8147): 256 of int[] (72000 elements) (256 unique instances)
05-02 14:50:16.815: W/dalvikvm(8147): 256 of long[] (8 elements) (1 unique instances)
05-02 14:50:16.815: E/dalvikvm(8147): Failed adding to JNI pinned array ref table (1024 entries)
05-02 14:50:16.815: I/dalvikvm(8147): "main" prio=5 tid=1 RUNNABLE
05-02 14:50:16.815: I/dalvikvm(8147): | group="main" sCount=0 dsCount=0 obj=0x41c8a700 self=0x400b2010
05-02 14:50:16.815: I/dalvikvm(8147): | sysTid=8147 nice=0 sched=0/0 cgrp=apps handle=1074671408
05-02 14:50:16.815: I/dalvikvm(8147): | schedstat=( 0 0 0 ) utm=116 stm=48 core=0
05-02 14:50:16.815: I/dalvikvm(8147): at org.opencv.core.Mat.nPutB(Native Method)
05-02 14:50:16.815: I/dalvikvm(8147): at org.opencv.core.Mat.put(Mat.java:2537)
05-02 14:50:16.815: I/dalvikvm(8147): at org.opencv.android.JavaCameraView.onPreviewFrame(JavaCameraView.java:239)
05-02 14:50:16.815: I/dalvikvm(8147): at com.test.camera.CvJavaCameraView.onPreviewFrame(CvJavaCameraView.java:119)
05-02 14:50:16.845: I/dalvikvm(8147): at android.hardware.Camera$EventHandler.handleMessage(Camera.java:775)
05-02 14:50:16.845: I/dalvikvm(8147): at android.os.Handler.dispatchMessage(Handler.java:99)
05-02 14:50:16.845: I/dalvikvm(8147): at android.os.Looper.loop(Looper.java:137)
05-02 14:50:16.845: I/dalvikvm(8147): at android.app.ActivityThread.main(ActivityThread.java:4797)
05-02 14:50:16.845: I/dalvikvm(8147): at java.lang.reflect.Method.invokeNative(Native Method)
05-02 14:50:16.845: I/dalvikvm(8147): at java.lang.reflect.Method.invoke(Method.java:511)
05-02 14:50:16.845: I/dalvikvm(8147): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:804)
05-02 14:50:16.845: I/dalvikvm(8147): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:571)
05-02 14:50:16.845: I/dalvikvm(8147): at dalvik.system.NativeStart.main(Native Method)
05-02 14:50:16.845: E/dalvikvm(8147): VM aborting