根据这个帖子,由于本机代码泄漏,我不断地收到此错误提示:
然而,在我看来,AttachCurrentThread是在泄漏。我尝试了这段代码,但它泄漏了。
// 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());
}
然后我只需注释掉所有内容,程序就不再泄漏并一直运行 :(
// 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泄漏的问题吗?
谢谢。