diff --git a/app/src/main/jni/netguard/netguard.c b/app/src/main/jni/netguard/netguard.c index fd483306..f7328dd7 100644 --- a/app/src/main/jni/netguard/netguard.c +++ b/app/src/main/jni/netguard/netguard.c @@ -57,15 +57,19 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) { const char *packet = "eu/faircode/netguard/Packet"; clsPacket = jniGlobalRef(env, jniFindClass(env, packet)); + ng_add_alloc(clsPacket, "clsPacket"); const char *allowed = "eu/faircode/netguard/Allowed"; clsAllowed = jniGlobalRef(env, jniFindClass(env, allowed)); + ng_add_alloc(clsAllowed, "clsAllowed"); const char *rr = "eu/faircode/netguard/ResourceRecord"; clsRR = jniGlobalRef(env, jniFindClass(env, rr)); + ng_add_alloc(clsRR, "clsRR"); const char *usage = "eu/faircode/netguard/Usage"; clsUsage = jniGlobalRef(env, jniFindClass(env, usage)); + ng_add_alloc(clsUsage, "clsUsage"); // Raise file number limit to maximum struct rlimit rlim; @@ -91,7 +95,13 @@ void JNI_OnUnload(JavaVM *vm, void *reserved) { log_android(ANDROID_LOG_INFO, "JNI load GetEnv failed"); else { (*env)->DeleteGlobalRef(env, clsPacket); + (*env)->DeleteGlobalRef(env, clsAllowed); (*env)->DeleteGlobalRef(env, clsRR); + (*env)->DeleteGlobalRef(env, clsUsage); + ng_delete_alloc(clsPacket, __FILE__, __LINE__); + ng_delete_alloc(clsAllowed, __FILE__, __LINE__); + ng_delete_alloc(clsRR, __FILE__, __LINE__); + ng_delete_alloc(clsUsage, __FILE__, __LINE__); } }