Memory leaks with UIWebView and NSURL: already spent several days trying to solve them
- by Sander de Jong
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?