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

查看:137
本文介绍了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.

基本上,它归结为一个 URLRequest 时, loadRequest:调用 UIWebView 从一个 NSURL 构建,它​​引用了一个文件URL,该文件位于应用程序包中的一个文件中,该文件位于Xcode通过引用包含的文件夹中。 Phew。

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。)然后通过选择为任何添加的文件夹创建文件夹引用将XHTML文件夹添加到您的项目

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 属性到nil,使用 alloc / init ,而不是自动释放 NSURLRequest (和/或 NSURL s)...

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)...

回答类似问题(将共享网址缓存设置为空),但没有帮助。

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

任何人都可以帮助?

推荐答案

忘记了这个问题。

我假设4.2同样。

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

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