Hi everyone,
I have some problems with the use of a webview. When i load a webview in activity the memory goes up for about 12/15mb, normally when i dispose the findviewbyid objects in ondestroy() and do a gc.collect(gc.maxgeneration) after that the system gets the memory back. But in this case it keeps the memory. Normally after clicking through the app it releases the memory after some time.
http://code.google.com/p/android/issues/detail?id=9375
This is because there is a kind of reference still alive with the activity that the webview needs? Its seems to be a bug in android himself but i found someone with a solution i wanted to try but i need to use reflection. Not my best thing...
http://stackoverflow.com/questions/3130654/memory-leak-in-webview -> the NoLeakingWebView answer.
He makes a extension of the webview does some kind of reflection. This piece of code i dont know how to port it to c#.
private static Field sConfigCallback;
static {
try {
sConfigCallback = Class.forName("android.webkit.BrowserFrame").getDeclaredField("sConfigCallback");
sConfigCallback.setAccessible(true);
} catch (Exception e) {
// ignored
}
}
I noticed that there is no Field object available? It that true? I have tried:
IntPtr class_ref = JNIEnv.FindClass("android.webkit.BrowserFrame"); IntPtr sConfigCallback = JNIEnv.GetFieldID(class_ref, "sConfigCallback", "");
This not the correct way and i dont have any idea how to this right.
I hope some can help me out. Maybe with a answer how to prevent this leak and maybe how to port this custom webview to c# android.
Thanks in advance.
Iwan