我已经在世界各地搜索过,如果它是在 JNI 代码中创建的,我们应该 DeleteLocalRef
,如果对象是新的并由 Java 代码返回,我是否也应该删除它?如:
// in java code
public SomeObject funcInJavaCode() {
return new SomeObject();
}
// in jni code
funcInJNI {
jobject obj = env->CallObjectMethod(...);
...
// do i have to delete the obj here???
env->DeleteLocalRef(obj);
}
谢谢