我为自己的应用创建了自定义浏览器。每当我将URL请求加载到Web视图中时,都会看到内存泄漏。请注意,不会显示回溯。应用程序有一个webview,下面是一个刷新按钮。
刷新按钮上的代码如下
- (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"]]];
}
请尽早帮我解决这个问题