采用资产时,机器人的WebView内存泄漏机器人、内存、资产、WebView

2023-09-04 05:33:58 作者:英文

最近我注意到,当我加载的WebView基于关​​闭code从文件(使用的资产或本地目录),web视图会泄漏内存,一旦destroy()方法被调用。我已经把范围缩小到一个引用的问题。该计划/ web视图,使原来的观点的副本,并失去了JNI表中的引用 - 这最终导致程序后,512项崩溃

I've recently noticed that when I load a webview based off code from a file (using assets or a local directory), the WebView will leak the memory once the destroy() method is called. I've narrowed it down to a referencing issue. The program/webview makes copies of the original view and loses the references in the JNI table - this eventually causes the program to crash after 512 entries.

我已经看到了这篇文章,但不渗漏的WebView修复似乎不使用HTML的资产或外部文件夹的工作。

I have seen this article, but the non-leaking webview fix does not seem to work with HTML in the assets or external folders.

内存泄漏的WebView

应用完全基于服务器的时候这个问题不存在;但是,我需要的应用程序能够为同步数据,并更新脱机回购这些观点。

The issue does not exist when the application is entirely server based; but, I need the application to be able to "sync" data and update the offline repo with these views.

另外的信息:我已经采取了webviews,把他们在一个ViewPager允许滚动。在3.2.4 / 1不存在这个问题,但已经出现在4.0.3。我得到了很多JNI警告,(没能找到入口),他们仍然存在后的意见被破坏。我看着它通过HPROF,我已经注意到了,HTML下榻残留在失去了变数。

Further info: I have taken the webviews and put them in a ViewPager to allow for scrolling. This issue did not exist in 3.2.4/1 but has appeared in 4.0.3. I get a lot of JNI Warnings, (failed to find entry) and they still exist after the views are destroyed. I've looked at it through the hprof, and I have noticed that the HTML is staying residual in lost variables.

如何纠正这种行为将AP preciated任何光线。

Any light on how to correct this behavior would be appreciated.

编辑:

就死机具体细节

Failed adding to JNI local ref table (has 512 entries)
"Thread-375" prio=5 tid=15 RUNNABLE
| group="main" sCount=0 dsCount=0 obj=0x41504a90 self=0x1a9cf80
| sysTid=10314 nice=0 sched=0/0 cgrp=default handle=27159240
| schedstat=( 455083000 66745000 774 ) utm=30 stm=15 core=3

at android.content.res.AssetManager.readAsset(Native Method)
at android.content.res.AssetManager.access$700(AssetManager.java:35)
at android.content.res.AssetManager$AssetInputStream.read(AssetManager.java:573)
at dalvik.system.NativeStart.run(Native Method)

更新:

要解决这个问题,必须从SD卡,或一些其他存储机构加载。该错误是永久性的,当加载JavaScript文件,我不知道它是否固定在Chrome浏览器,但它似乎并没有固定在浏览器的最新操作系统。

To fix this issue, you have to load from the SD Card, or some other storage mechanism. The bug is permanent when a Javascript file is loaded, I don't know if it's fixed in Chrome, but it does not seem to be fixed in Browser in the newest OS.

推荐答案

.destroy() - >销毁此的WebView的内部状态。后这个web视图已经从该视图体系中除去此方法应被调用

.destroy() --> Destroys the internal state of this WebView. This method should be called after this WebView has been removed from the view system.