JNI Explanation DeleteLocalRef
Question 1:
jstring jstrKey;
for(int i=1;i<=1000;++i) {
LPWSTR strKey = L"string";
jstrKey = env->NewString((jchar *)strKey, wcslen(strKey));
}
env->DeleteLocalRef(jstrKey);
Question 2:
for(int i=1;i<=1000++i) {
LPWSTR strKey = L"string";
jstring jstrKey = env->NewString((jchar *)strKey, wcslen(strKey));
env->DeleteLocalRef(jstrKey);
}
Am I using DeleteLocalRef correctly in both questions?
Especially in question 1, I remove the local ref after the loop. I think this is correct, and you do not need to call deleteelocalref inside the loop, since I am not creating any new local links.
So there are no problems with use DeleteLocalRef?