jni 修bug
时间:2014-04-29 14:46:40
收藏:0
阅读:411
1. ReferenceTable overflow (max=512)
内存泄露,程序运行一段时间就挂掉了.
在利用反射调用java中的函数需要释放掉查找到的类
void publishJavaProgress(JNIEnv * env, jobject obj, jint progress)
{
jclass clazz = (*env)->FindClass(env,"com/itcast/lame/LameActivity"); //String
if (clazz == 0) LOGI("dont find class");
jmethodID methodid = (*env)->GetMethodID(env, clazz, "setConvertProgress", "(I)V");
if (methodid == 0) LOGI("dont find method");
(*env)->CallVoidMethod(env,obj,methodid,progress);
(*env)->DeleteLocalRef(env, clazz);
//此释放掉!!!
}
}
评论(0)