LeakCanary spots Android WebView memory leak -
i've been using tool leakcanary spot memory leakages in application. seems webviewactivity leaks everytime.
i created simple application test leakages. start activity webview inside xml layout file/inflate activity context. js off. default expect simple webviewclient keeping redirection within webview. leaks every time.
i've done plenty of research, way prevent start webviewactivity process , kill inside ondestroy. method has own disadvantages.
the leak happens every time on devices running 5.0+, haven't checked 4.3 , below.
the leak info pasted below:
in com.example.webviewmemoryleaktest:1.0:1. * com.example.webviewmemoryleaktest.webviewactivity has leaked: * gc root android.os.resultreceiver$myresultreceiver.this$0 * references org.chromium.content.browser.contentviewcore$2$1.this$1 (anonymous class extends android.os.resultreceiver) * references org.chromium.content.browser.contentviewcore$2.this$0 * references org.chromium.content.browser.contentviewcore.mcontext * references com.android.webview.chromium.resourcescontextwrapperfactory$webviewcontextwrapper.mbase * leaks com.example.webviewmemoryleaktest.webviewactivity instance
- reference key: 9a0346cf-6ad9-4b07-9329-a975d8fa3cbe
- device: lge google nexus 4 occam
- android version: 5.1 api: 22
- durations: watch=5139ms, gc=188ms, heap dump=2822ms, analysis=30918ms
appreciate if help. thanks!
private resultreceiver mresultreceiver = new resultreceiver(new handler()) { @override public void onreceiveresult(int resultcode, bundle resultdata) { getcontentviewclient().onimestatechangerequested( resultcode == inputmethodmanager.result_shown || resultcode == inputmethodmanager.result_unchanged_shown); if (resultcode == inputmethodmanager.result_shown) { // if osk newly shown, delay form focus until // onsizechanged (in order adjust relative // new size). // todo(jdduke): should not assume onsizechanged // called, crbug.com/294908. getcontainerview().getwindowvisibledisplayframe( mfocuspreoskviewportrect); } else if (hasfocus() && resultcode == inputmethodmanager.result_unchanged_shown) { // if osk there, focus form immediately. assert mwebcontents != null; mwebcontents.scrollfocusededitablenodeintoview(); } } }; @override public resultreceiver getnewshowkeyboardreceiver() { return mresultreceiver; }
make mresultreceiver private.
Comments
Post a Comment