UIWebView 泄漏?有人可以确认吗? [英] UIWebView leak? Can someone confirm?

查看:18
本文介绍了UIWebView 泄漏?有人可以确认吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在对我当前的项目进行泄漏测试,但我被难住了.我一直在疯狂浏览并尝试了除鸡肉牺牲之外的所有内容.我刚刚从头开始创建了一个小玩具项目应用程序,我可以在其中复制泄漏.所以要么 UIWebView 有漏洞,要么我在做一些非常愚蠢的事情.

I was leak-testing my current project and I'm stumped. I've been browsing like crazy and tried everything except chicken sacrifice. I just created a tiny toy project app from scratch and I can duplicate the leak in there. So either UIWebView has a leak or I'm doing something really silly.

本质上,它归结为对 UIWebView 对象的 loadRequest: 调用,给定从 NSURL<构建的 URLRequest/code> 引用文件 URL,用于应用程序包中的文件,该文件位于 Xcode 通过引用包含的文件夹中.呼.

Essentially, it boils down to a loadRequest: call to a UIWebView object, given an URLRequest built from an NSURL which references a file URL, for a file in the app bundle, which lives inside a folder that Xcode is including by reference. Phew.

泄漏是间歇性的,但仍有约 75% 的时间发生(在大约 20 次测试中发生了大约 15 次).它发生在设备上——这在模拟器中不会泄漏.我正在使用 iPhone OS 3.1.3 的原始(第一代)iPod Touch 测试同时针对 iPhone OS 3.1.2 和 3.1.3.

The leak is intermittent but still happens ~75% of the time (in about 20 tests it happened about 15 times). It only happens on the device -- this does not leak in the simulator. I am testing targeting both iPhone OS 3.1.2 and 3.1.3, on an original (1st Gen) iPod Touch that is using iPhone OS 3.1.3.

要重现,只需从头开始创建一个项目.将 UIWebView 添加到 RootViewController 的 .xib,通过 IBOutlet 将其连接起来.在 Finder 中,在项目文件夹中创建一个名为html"的文件夹.在该文件夹内,创建一个名为dummy.html"的文件,其中包含Test"一词.(不需要必须是有效的 HTML.)然后通过选择为任何添加的文件夹创建文件夹引用"将 html 文件夹添加到您在 Xcode 中的项目中

To reproduce, just create a project from scratch. Add a UIWebView to the RootViewController's .xib, hook it up via IBOutlet. In the Finder, create a folder named "html" inside your project's folder. Inside that folder, create a file named "dummy.html" that has the word "Test" in it. (Does not need to be valid HTML.) Then add the html folder to your project in Xcode by choosing "Create Folder References for any added folders"

将以下内容添加到 viewDidLoad

NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
NSString* filePath = [[resourcePath stringByAppendingPathComponent:@"html"] stringByAppendingPathComponent:@"dummy.html"];
NSURL* url = [[NSURL alloc] initFileURLWithPath:filePath];
NSURLRequest* request = [NSURLRequest requestWithURL:url]; // <-- this creates the leak!
[browserView loadRequest:request];
[url release];

我已经尝试了从为 UIWebView 设置委托和实现 UIWebViewDelegate 到不在 IB 中设置委托、不在 IB 中设置委托和显式设置的所有方法Web 视图的 delegate 属性为零,以使用 alloc/init 而不是获取自动发布的 NSURLRequests(和/或 NSURLs)...

I've tried everything from setting delegate for the UIWebView and implementing UIWebViewDelegate, to not setting a delegate in IB, to not setting a delegate in IB and explicitly setting the web view's delegate property to nil, to using alloc/init instead of getting autoreleased NSURLRequests (and/or NSURLs)...

我尝试了 一个类似的问题(将共享 URL 缓存设置为空),但没有帮助.

I tried the answer to a similar question (setting the shared URL cache to empty) and that did not help.

有人可以帮忙吗?

推荐答案

忘记这个问题了.

4.1 中不存在泄漏.我认为 4.2 也是如此.

The leak is not present in 4.1. I would assume the same for 4.2.

这篇关于UIWebView 泄漏?有人可以确认吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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