"JNI错误(应用程序错误):弱的全局引用表溢出"为什么? [英] "JNI ERROR (app bug): weak global reference table overflow" why?
问题描述
由于此线程的本机代码泄漏,我不断收到此错误:
I keep getting this error due to a leak in my native code according to this thread:
ReferenceTable溢出(max = 512)JNI
但是,在我看来,AttachCurrentThread泄漏了.我尝试了这段代码,然后泄漏了
yet, it seems to me the the AttachCurrentThread leaks. I tried this code and it leaks
// this code LEAKS!
// C++:
void Engine::UpdateCamera(float x, float y, float z) {
JNIEnv *jni;
app_->activity->vm->AttachCurrentThread(&jni, NULL);
//Do nothing
app_->activity->vm->DetachCurrentThread();
return;
}
// Java
public void updateCamera(final float x, final float y, final float z) {
if (_label2 == null)
return;
StackTraceElement trace = new Exception().getStackTrace()[0];
Log.e(APP_TAG, "Called:" +
trace.getClassName() + "->" + trace.getMethodName() + ":" + trace.getLineNumber());
}
然后我只是注释掉所有内容,该程序停止泄漏并永远运行:(
Then I simply commented out everything and the program stopped leaking and ran forever :(
// this code never leaks, but it does not do anything either
void Engine::UpdateCamera(float x, float y, float z) {
JNIEnv *jni;
//app_->activity->vm->AttachCurrentThread(&jni, NULL);
//app_->activity->vm->DetachCurrentThread();
return;
}
有人遇到AttachCurrentThread泄漏问题吗?
Has anyone experienced leaking issues with AttachCurrentThread?
谢谢.
推荐答案
您是否已连接到调试器?如果是这样,请断开连接,您可能会发现弱引用表已返回合理的值.
Are you connected to the debugger? If so, disconnect and you may find the weak reference table returns to a reasonable value.
我有同样的问题;如果我与调试器一起运行,则会发生这种情况.
I had this same problem; if I run with the debugger, this occurs.
这篇关于"JNI错误(应用程序错误):弱的全局引用表溢出"为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!