[webkit-dev] Leak in UIWebView?

Simon Fraser simon.fraser at apple.com
Tue Apr 20 15:47:22 PDT 2010

On Apr 20, 2010, at 3:35 PM, Thomas Hauk wrote:

> I've posted this question to devforums.apple.com as well as to Stack Overflow (go to http://stackoverflow.com/questions/2557964/uiwebview-leak-can-someone-confirm to see it) and have not gotten any answer, so now I'm reaching out to webkit-dev for some help.
> I am developing an iPhone application that contains embedded HTML resources. The following code leaks memory only on the device (at least 75% of the time) when I try to create a NSURLRequest for an HTML file in the application bundle. My base SDK is 3.1.2 (also tried with 3.1.3), and I'm running this on a first-gen iPod Touch running 3.1.3. This does not leak in the Simulator. If I comment out the call to loadRequest: all is well.
> NSString* resourcePath = [[NSBundle mainBundle] resourcePath];
> NSString* filePath = [[resourcePath stringByAppendingPathComponent:@"html"]
>                       stringByAppendingPathComponent:@"dummy.html"];
> NSURL* url = [[NSURL alloc] initFileURLWithPath:filePath];
> NSURLRequest* request = [NSURLRequest requestWithURL:url]; // leak!
> [browserView loadRequest:request];
> [url release];
> I can reproduce this leak in a freshly-generated Window-based or Navigation-based project, with essentially only the above code plus the addition of a UIWebView object in the generated xib. The stack trace for the leak seems to be entirely within the "Apple" side of things. The HTML file can be as simple as a file with the word "test" in it (i.e. it doesn't need to be valid HTML).
> What am I doing wrong?

Not filing this at http://bugreporter.apple.com :)


More information about the webkit-dev mailing list