5
안녕하세요, UIWebView 기본 메모리 누수 문제가 있습니다. 다른 컨트롤러에서 UITableView에 링크가있는 WebView 표시 페이지가 있습니다. 탐색기와 WebView 함께 컨트롤러를 밀고 재산을 보유하십시오. 내가 좋아하는 인터넷에 모든 노력을 한IOS UIWebView 누설
는 :
-(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];
}
:
[[NSUserDefaults standardUserDefaults] setInteger:0 forKey:@"WebKitCacheModelPreferenceKey"];
//Clear cache of UIWebView
NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil];
[NSURLCache setSharedURLCache:sharedCache];
[sharedCache release];
sharedCache = nil;
[[NSURLCache sharedURLCache] removeAllCachedResponses];
이 내 코드입니다
이제는 시뮬레이터 4.2와 4.3에서만 테스트했습니다. xcode 4를 사용합니다. 네비게이터에서 뒤로 버튼을 누르면이 누출이 발생합니다. http://postimage.org/image/368r0g0xw/
어떤 도움이 난 지금, 감사
코드 줄 중 하나가 다른 방법으로 표시되는 경우 실제 코드를 게시 할 수 있습니까? 그건 컴파일되지 않습니다. myRequest가 할당/할당되는 곳은 어디입니까? 'link'는 어떨까요? 'UIWebView'에 대한 델리게이트를 설정 했습니까? – Jim
죄송합니다. 지금 코드를 게시하겠습니다. –