Skip to content

Instantly share code, notes, and snippets.

@rosuH
Created February 22, 2018 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rosuH/15c15b066434de764e18a04f7d9c933f to your computer and use it in GitHub Desktop.
Save rosuH/15c15b066434de764e18a04f7d9c933f to your computer and use it in GitHub Desktop.
Avoid webview memory leaks
@Override
protected void onDestroy() {
if(mWebView !=null ){
mWebView.loadDataWithBaseURL(null, "", "text/html",
"utf-8", null);
((ViewGroup)mWebView.getParent()).removeView(mWebView);
mWebView.destroy();
mWebView = null;
}
super.onDestroy();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment