(lots of) UIWebView memory leaks((很多)UIWebView 内存泄漏)
问题描述
我从其他帖子中看到 UIWebView 存在内存泄漏问题.但是,由于我泄漏的对象数量众多,我不得不怀疑我是否做错了什么.'Leaks' 报告了关于打开 UIWebView、加载页面和关闭(它是 Facebook 登录页面)的 60 次泄漏.我已经检查了这些对象中的每一个的堆栈跟踪,它们从未接触过我的代码.它们要么都在一个单独的线程中(我只使用主线程),要么从主"转到一堆灰色的内部方法.这是 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..?
肖恩
这是泄漏的捕获:
推荐答案
很抱歉这么快就回答了我自己的问题,但我刚刚发现了问题.
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 内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:(很多)UIWebView 内存泄漏
基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01