(很多)UIWebView内存泄漏 [英] (lots of) UIWebView memory leaks

查看:84
本文介绍了(很多)UIWebView内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从其他帖子中看到UIWebView存在内存泄漏问题。
然而,随着我泄漏的物体数量,我不得不怀疑自己做错了什么。 'Leaks'报告了打开UIWebView,加载页面和关闭(这是Facebook登录页面)的60次泄密。我检查了每个这些对象的堆栈跟踪,它们从不触及我的代码。它们都在一个单独的线程中(我只使用主线程),或者从'main'转到一堆灰色的内部方法。这是从UIWebView预期的吗?我正在运行最新的固件,我认为他们现在已经解决了这个问题。
顺便说一下,我在设备上看到了这个。
我也尝试检查苹果网站上的错误,但除了问题ID之外没有办法搜索..?

I've seen from other posts that there are memory leaking issues with UIWebView. However, with the amount of objects that I have leaking, I have to wonder if I'm doing something wrong. 'Leaks' reports about 60 leaks for opening a UIWebView, loading a page and closing (it's the Facebook login page). I've check the stack trace for every one of these objects, and they never touch my code. They're all either in a separate thread (I only use the main thread), or go from 'main' to a bunch of internal methods that are greyed out. Is this expected from UIWebView? I'm running the latest firmware, and I think they would have fixed this by now. I'm seeing this on the device, by the way. I also tried checking for bugs on the apple site, but there's no way to search other than by issue ID..?

Shaun

这是泄漏的捕获:

推荐答案

很抱歉这么快回答我自己的问题,但我刚发现问题。

Sorry to answer my own question so quickly, but I just found the problem.

如果您为委托方法返回NO:

If you return NO for the delegate method:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;

然后释放UIWebView,它将如上所述泄漏。返回YES修复了该问题。至少对我而言,到目前为止所有固件版本都会发生这种情况(4.3.3)。我正在向Apple提交一个错误。

and then release the UIWebView, it will leak as described above. Returning YES fixes the issue. At least for me, this is happening on all firmware revisions up to now (4.3.3). I am filing a bug with Apple.

这篇关于(很多)UIWebView内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆