在android中调用jni,出现ReferenceTable overflow (max=1024)

hmxingkong 2013-05-02 04:36:02
小弟最近入手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
...全文
522 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
ysmme 2013-10-29
  • 打赏
  • 举报
回复
楼主 你好 我也出现1024溢出 但是JNI不是我写的我是调用的 问题是出现在JNI函数中吗?还是java调用中没有释放还是没太看懂能告诉我吗谢谢
hmxingkong 2013-05-02
  • 打赏
  • 举报
回复
问题解决,同事发现是return引起的,jni方法中有多处return,但释放只出现在最后一个return,所以入股非正常跑完程序的话就执行不到这个资源释放了,大意、大意

80,432

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧