I want to know how to free the instance of c++ class. I tried like this but error occurred.
Live *pLive = Live::getInstance();
// do something with pLive
env->DeleteLocalRef(reinterpret_cast<jobject>(pLive));
I need your help. Thank you.
I want to know how to free the instance of c++ class. I tried like this but error occurred.
Live *pLive = Live::getInstance();
// do something with pLive
env->DeleteLocalRef(reinterpret_cast<jobject>(pLive));
I need your help. Thank you.
Copyright © 2021 Jogjafile Inc.
Since you're not calling anything on env to create the object, I assume Live::getInstance returns a C++ object and not a JNI object? In that case, use delete. You only use DeleteLocalRef on a JNI object. (A JNI object is an object that actually exists inside the JVM and is directly accessible in Java). Trying to DeleteLocalRef on a C++ object will always crash, as its not in the JVM's shared memory