mirror of
https://github.com/M66B/NetGuard.git
synced 2025-01-03 13:54:09 +00:00
Conditional memory profiling
This commit is contained in:
parent
aadf337df1
commit
e81d11ffc6
1 changed files with 5 additions and 3 deletions
|
@ -357,9 +357,7 @@ Java_eu_faircode_netguard_Util_jni_1getprop(JNIEnv *env, jclass type, jstring na
|
||||||
(*env)->ReleaseStringUTFChars(env, name_, name);
|
(*env)->ReleaseStringUTFChars(env, name_, name);
|
||||||
ng_delete_alloc(name);
|
ng_delete_alloc(name);
|
||||||
|
|
||||||
jstring result = (*env)->NewStringUTF(env, value);
|
return (*env)->NewStringUTF(env, value); // Freed by Java
|
||||||
ng_add_alloc(result, "result");
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL
|
JNIEXPORT jboolean JNICALL
|
||||||
|
@ -983,6 +981,7 @@ struct alloc_record *alloc = NULL;
|
||||||
pthread_mutex_t *alock = NULL;
|
pthread_mutex_t *alock = NULL;
|
||||||
|
|
||||||
void ng_add_alloc(void *ptr, const char *tag) {
|
void ng_add_alloc(void *ptr, const char *tag) {
|
||||||
|
#ifdef PROFILE_MEMORY
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1015,9 +1014,11 @@ void ng_add_alloc(void *ptr, const char *tag) {
|
||||||
|
|
||||||
if (pthread_mutex_unlock(alock))
|
if (pthread_mutex_unlock(alock))
|
||||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ng_delete_alloc(void *ptr) {
|
void ng_delete_alloc(void *ptr) {
|
||||||
|
#ifdef PROFILE_MEMORY
|
||||||
if (ptr == NULL)
|
if (ptr == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1046,6 +1047,7 @@ void ng_delete_alloc(void *ptr) {
|
||||||
|
|
||||||
if (pthread_mutex_unlock(alock))
|
if (pthread_mutex_unlock(alock))
|
||||||
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
log_android(ANDROID_LOG_ERROR, "pthread_mutex_unlock failed");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *ng_malloc(size_t __byte_count, const char *tag) {
|
void *ng_malloc(size_t __byte_count, const char *tag) {
|
||||||
|
|
Loading…
Reference in a new issue