Memory Leak in UIWebview on loading NSURLRequest

空扰寡人 提交于 2019-12-11 02:06:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!