Please help! Have been staring at this for 12 hours; and have looked online and can't find solution.
In my application, I use 2 UIView controls in separate pages/controllers:
Just to isolate my code, and make it easier to explain, I created a new view based project called "MyTestApplication"
1 - I added a simple NSData dataWithContentsOfUrl in the delegate function.
NSData *imageData = [NSData dataWithContentsOfURL: [NSURL URLWithString:@"http://www.google.com/intl/en_ALL/images/logo.gif"]];
(Nothing to release here since it's all using convenience functions)
alt text http://img.skitch.com/20081110-j5tn5n7ixph95ys4rpchibaw5p.preview.jpg
View Image
2 - Run it to verify no leaks (as expected)
alt text http://img.skitch.com/20081110-fy2qrkgy47hm4fe2f1aakd4muw.preview.jpg
3 - Open the ViewController.xib and simply add a UIWebView from the library (no need to wire it up)
alt text http://img.skitch.com/20081110-d63c3yh1a1kqiciy73q8uyd68j.preview.jpg
4 - Run it to verify there are leaks! (why???)
alt text http://img.skitch.com/20081110-qtxcfwntbcc3csabda3r6nfjg6.preview.jpg
What am I doing wrong? Please help!
Why would NSData cause memory leak if I'm using UIWebView? I just don't get it. Thanks.
I was also having trouble with leaks from NSData's dataWithContentsOfURL: in the iPhone simulator. I found that when I used the other convenience method (dataWithContentsOfURL:options:error:)?I would not get the memory leak.
dataWithContentsOfURL:
dataWithContentsOfURL:options:error:
My code looked something like this:
NSURL *url = [NSURL URLWithString:urlString]; NSError *error = nil; NSData *data = [NSData dataWithContentsOfURL:url options:0 error:&error];
Link to documentation
1.4m articles
1.4m replys
5 comments
57.0k users