I'm trying to cause a leak using this native method from my app. I can see "Method returned." in my Logs but I don't seem to lose any RAM. I'm using(MemoryInfo.availMem / 1048576L) for tracking usage.
JNIEXPORT jstring JNICALL Java_com_app_native_Wrapper_causeLeak(JNIEnv *je, jclass jc, jint bytes) {
char *p_array = calloc(bytes,sizeof(char));
return (*je)->NewStringUTF(je, "Method returned.");
}
And trying to cause 10MB leak via this method:
Wrapper.causeLeak(10 * 1024 * 1024)
EDIT:
I'm doing this because I want to test my app in a low memory situation.