update jni for memory leak detection
This commit is contained in:
parent
dcfbbe8a58
commit
a5bfb0d670
|
@ -9,6 +9,14 @@ extern "C" {
|
|||
#endif
|
||||
#undef com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE
|
||||
#define com_taosdata_jdbc_TSDBJNIConnector_INVALID_CONNECTION_POINTER_VALUE 0LL
|
||||
/*
|
||||
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||
* Method:
|
||||
* Signature: (Ljava/lang/String;)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_detectMemoryLeakImp
|
||||
(JNIEnv *, jclass, jstring);
|
||||
|
||||
/*
|
||||
* Class: com_taosdata_jdbc_TSDBJNIConnector
|
||||
* Method: initImp
|
||||
|
|
|
@ -111,6 +111,18 @@ void jniGetGlobalMethod(JNIEnv *env) {
|
|||
jniTrace("native method register finished");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_detectMemoryLeakImp(JNIEnv *env, jobject jobj, jstring jPath) {
|
||||
if (jPath != NULL) {
|
||||
const char *path = (*env)->GetStringUTFChars(env, jPath, NULL);
|
||||
taos_dump_memory_leak_at_exit(path);
|
||||
(*env)->ReleaseStringUTFChars(env, jPath, path);
|
||||
} else {
|
||||
taos_dump_memory_leak_at_exit(NULL);
|
||||
}
|
||||
|
||||
jniGetGlobalMethod(env);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_taosdata_jdbc_TSDBJNIConnector_initImp(JNIEnv *env, jobject jobj, jstring jconfigDir) {
|
||||
if (jconfigDir != NULL) {
|
||||
const char *confDir = (*env)->GetStringUTFChars(env, jconfigDir, NULL);
|
||||
|
|
|
@ -310,6 +310,11 @@ static void dump_memory_leak_at_sig(int sig) {
|
|||
}
|
||||
|
||||
void taos_dump_memory_leak_at_exit(const char* path) {
|
||||
if (fpMemLeak != NULL) {
|
||||
printf("memory leak detection already enabled.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (path == NULL || path[0] == 0) {
|
||||
fpMemLeak = stdout;
|
||||
} else if ((fpMemLeak = fopen(path, "w")) == NULL) {
|
||||
|
|
Loading…
Reference in New Issue