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