I think everyone knows this problem. It exists on all versions of android and how to get rid of it, I have not yet found. When you open the web-based activation, the app eats an additional 8 megabytes (maybe more). When the window is closed (and, accordingly, all kinds of clear, destroy, = null are called), the wrinkle is not released. Moreover, when entering activation again, more and more memory is leaking. The method of rendering the creation of a webview inside code, and not markup does not help. Tell me how to fix it?
Update
public class CarWebViewActivity extends Activity { @Override public void onCreate(Bundle saved) { super.onCreate(saved); setContentView(R.layout.web_layout); Bundle extras = getIntent().getExtras(); final String href = extras.getString("href"); ((TextView) findViewById(R.id.header_title)).setText(extras.getString("title")); findViewById(R.id.web_layout_top_bar_button_reload).setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (href != null) webView.loadUrl(href); } }); LinearLayout root = (LinearLayout) findViewById(R.id.web_layout_root); webView = new WebView(getApplicationContext()); root.addView(webView); webView.setWebViewClient(new HelloWebViewClient()); if (href != null) webView.loadUrl(href); webView.setWebChromeClient(new MyWebChromeClient()); webView.getSettings().setBlockNetworkImage(false); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setLoadsImagesAutomatically(true); } WebView webView; private final class HelloWebViewClient extends WebViewClient { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); return true; } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.e("Ошибка страницы", "ошибка страницы"); AlertDialog alertDialog = new AlertDialog.Builder(CarWebViewActivity.this) .setMessage("Для отображения страницы необходимо интернет соединение") .setPositiveButton("Вернуться", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialogInterface, int i) { finish(); } }).show(); super.onReceivedError(view, errorCode, description, failingUrl); } } public final class MyWebChromeClient extends WebChromeClient { public void onProgressChanged(WebView view, int progress) { try { findViewById(R.id.progressinheader).setVisibility(View.VISIBLE); findViewById(R.id.web_layout_top_bar_button_reload).setVisibility(View.GONE); if (progress == 100) { findViewById(R.id.progressinheader).setVisibility(View.GONE); findViewById(R.id.web_layout_top_bar_button_reload).setVisibility(View.GONE); } } catch (Exception e) { } } } @Override public void onDestroy() { super.onDestroy(); webView.stopLoading(); webView.clearCache(true); webView.clearView(); webView.freeMemory(); webView.destroy(); webView = null; findViewById(R.id.progressinheader).setVisibility(View.GONE); } @Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.menu, menu); return true; } @Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.about_item: Intent intent = new Intent(getApplicationContext(), AboutActivity.class); startActivity(intent); break; default: return super.onOptionsItemSelected(item); } return true; } }
[GC.Collect();](http://msdn.microsoft.com/en-us/library/xe0c2357.aspx)
sure there is something similar in java - Specter