Memory leaks with UIWebView and NSURL: already spent several days trying to solve them
Posted
by Sander de Jong
on Stack Overflow
See other posts from Stack Overflow
or by Sander de Jong
Published on 2009-12-01T14:34:00Z
Indexed on
2010/04/29
21:17 UTC
Read the original article
Hit count: 591
I have already found a lot of information about how to solve memory leaks for iPhone Obj C code. The last two leaks keep me puzzled, I'm probably overlooking something. Maybe you can spot it.
Instruments reports 2 leaks for the following code (part of a UIViewController subclass):
(1) UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0,
0.0,
self.view.bounds.size.width,
self.view.bounds.size.height - LOWER_VERT_WINDOW_MARGIN)];
(2) webView.scalesPageToFit = YES;
(3) webView.dataDetectorTypes = UIDataDetectorTypeNone;
(4)
(5) NSURL *url = [NSURL fileURLWithPath:self.fullPathFileName isDirectory:NO];
(6) NSMutableURLRequest *urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
(7) [webView loadRequest:urlRequest];
(8) [urlRequest release], urlRequest = nil;
(9) [self.view addSubview:webView];
(10) [webView release], webView = nil;
Instruments claims 128 bytes are leaking in line 1, as well as 256 bytes in line 4. No idea if it means line 3 or line 5.
Does anybody have a clue what I'm overlooking?
© Stack Overflow or respective owner