问题
I have created a custom browser for my app. Whenever i load a url request into web view a memory leak is seen. Please note that no backtrace is shown. Application has a webview and a refresh button is given below it.
The code on refresh button is as follows
- (IBAction)refresh:(id)sender
{
// Some solution suggested by online community but in vain
[wvWebView loadHTMLString:@"" baseURL:nil];
[wvWebView stopLoading];
wvWebView.delegate = nil;
// Clearing cache Memory
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"];
[[NSURLCache sharedURLCache] removeAllCachedResponses];
[[NSURLCache sharedURLCache] setDiskCapacity:0];
[[NSURLCache sharedURLCache] setMemoryCapacity:0];
// Deleting all the cookies
for(NSHTTPCookie *cookie in [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies])
{
[[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
// Loading webview with desired url
[wvWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.google.com"]]];
}
Please help me to solve this issue as early as possible
来源:https://stackoverflow.com/questions/10088122/memory-leak-in-uiwebview-on-loading-nsurlrequest