UIWebview javascript 泄漏?
我之前已经发布过有关此问题的文章,但一直在努力想出解决方案。
基本上我的 iPad 应用程序中有一个 HTML5/jQuery 应用程序。每次我将图像加载到 UIWebView(HTML 应用程序)中时,分析器中的总体分配每次都会增加约 2MB。这听起来很正确,因为图像大约为 2MB。我正在使用标签中的数据符号来加载 Base64 图像。
IE
当我加载一定数量的图像(翻页)时,应用程序将崩溃。
该应用程序是一个电子书查看器,因此当我转向新的(之前未在当前会话中加载)时,分配会增加。但是,如果我返回到以前加载的页面,分配不会增加,并且页面加载速度比新页面更快。每次翻页都会向数据库发送一个请求,因此我开始认为泄漏不在 iOS 中,而可能在 HTML5 应用程序中。
对此有什么想法吗?我猜想 HTML 应用程序中可能会像 iOS 中一样容易出现泄漏。我该如何调试这个?
任何想法都非常感激。
谢谢
I've posted about this before but have been struggling to come up with a solution.
Basically I have a HTML5/jQuery app within my iPad app. Every time I load an image into the UIWebView (HTML App) the overall allocations in the profiler increases by about 2MB each time. This sounds about right because the image is approx 2MB's. I am using the data notation in the tag to load a Base64 image.
i.e.
When I load a certain number of images (page turns) the app will crash.
The app is an ebook viewer, so when I turn to a new (not previously loaded in current session) the allocations increase. But, if I turn back to a previiously loaded page the allocations don't increase and the page loads quicker than a new one. Every page turn sends a request to the database so i'm beginning to think the leak isn't in the iOS and that it could be in the HTML5 app.
Any ideas on this? I guess there could just as easily be a leak in the HTML app as there could be in iOS. How do I go about debugging this?
Any ideas greatly appreciated.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
HTTP 和 WebKit 喜欢保留资源的本地副本,以防万一您再次需要它。这可能就是你遇到的情况。
检查此问题的答案:是否可以阻止 NSURLRequest 缓存数据或在请求后删除缓存的数据?
HTTP and WebKit likes to keep a local copy of resources, just in case you will need it again. This may be what you encounter.
Check the answers to this question: Is it possible to prevent an NSURLRequest from caching data or remove cached data following a request?
这是 iOS 4 中无法修复的问题。
升级到 iOS5 后问题自行解决。
This was die an unfixable issue with iOS 4.
Issue resolved itself after upgrading to iOS5.