When adding JavaScript support setJavaScriptEnabled (true) , when I click on the links, the application starts to take up a lot of memory, when I don’t add support, everything works fine, I don’t know why, help me figure it out.
public void onCreate(Bundle savedInstanceState) { mWebView = new WebView(getApplicationContext()); mWebContainer = (FrameLayout) findViewById(R.id.web_container); mWebContainer.addView(mWebView); mWebView.getSettings().setUserAgentString(""); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.getSettings().setPluginsEnabled(true); mWebView.getSettings().setPluginState(PluginState.ON); mWebView.getSettings().setDatabaseEnabled(true); mWebView.getSettings().setGeolocationEnabled(true); mWebView.getSettings().setSupportZoom(true); mWebView.getSettings().setSavePassword(true); mWebView.getSettings().setSaveFormData(true); } private static class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } protected void onDestroy() { super.onDestroy(); mWebContainer.removeAllViews(); mWebView.destroy(); mWebView = null; System.gc(); } }
Created a simple webview - the same memory leak.