Hi, I am having problems with memory leak of UIWebView. I have my WebView display pages with links located in a UITableView from another controller. I click on the controller using WebView using the navigator and pass the link while preserving the properties of it.
I tried everything on the internet like:
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"];
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
sharedCache = nil;
[[NSURLCache sharedURLCache] removeAllCachedResponses];
this is my code:
-(void) viewWillAppear:(BOOL) animated
{
NSMutableURLRequest *_req=[[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:link] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:120];
[_req setHTTPShouldHandleCookies:NO];
[self setMyRequest:_req];
[req release];
}
[webView loadRequest:myRequest];
-(void) viewWillDisappear:(BOOL) Animated
{
[webView stopLoading];
[webView loadHTMLString:@"<html></html>" baseURL:nil];
}
- (void)dealloc {
[myRequest release];
[webView stopLoading];
[webView release];
[link release];
[super dealloc];
}
Now I tested only on simulators 4.2 and 4.3, I use xcode 4, I get this leak when I click the back button in the navigator.
And here is the code from my table controller
- (void)viewDidLoad {
webViewController=[[ItemDetail alloc] initWithNibName:@"ItemDetail" bundle:[NSBundle mainBundle] ];
[super viewDidLoad];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
webViewController.link=http:
[self.navigationController pushViewController:webViewController animated:YES];
}
-(void) dealloc
{
[webViewController release];
...
...
[super dealloc];
}
Here is the link to the screen: http://postimage.org/image/368r0g0xw/
Any help would be appreciated, Thanks
source
share