android webview内存泄漏原因

android混合开发中,经常会遇到webview加载很多页面的情况,很容易导致内存泄露;

内存泄露原因:参考文章https://blog.csdn.net/xygy8860/article/details/53334476?utm_source=itdadao&utm_medium=referral

webview内存泄露解决方式:

  1. 加载WebView的界面开启新进程,需要考虑进程间通讯的问题
  2. 动态添加webview,通过布局的viewgroup,使用viewgroup.add方式添加webview,销毁的时候先通过viewgroup.removeView(webview)删除webview,然后webview.destroy;另外传入webview的Context采用弱引用的方式

参考文章:https://blog.csdn.net/carson_ho/article/details/52693322

猜你喜欢

转载自blog.csdn.net/liangtianmeng/article/details/82179496
今日推荐