2014-09-19 2 views
0

내 iOS 앱에서 웹에서 비디오를 저장하도록 구현되었습니다. 비디오를 다운로드 할 때 메모리 사용이 계속 증가합니다. xcode에서 프로필을 사용하여 검사하고 비디오 당 증가하는 일부 malloc을 보았습니다. enter image description here메모리 할당 계속 유지

enter image description here 프로필에 익숙하지 않습니다. receivedData NSMUtableData 변수를 릴리스했습니다.

- (void) connectionDidFinishLoading:(NSURLConnection *)connection { 
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 

    NSString *documentsDirectry = [paths objectAtIndex:0]; 
    NSLog(@"Succeeded! Received %d bytes of data",[receivedData length]); 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
    NSString *filename = [NSString stringWithFormat:(@"video_%@.mp4"),videoURL]; 
    [receivedData writeToFile:[documentsDirectry stringByAppendingPathComponent:filename ] atomically:YES]; 
    receivedData = nil; 
    [receivedData release]; 
    progress.hidden = YES; 

}

응용 프로그램의 성능을 받고. 이 문제를 어떻게 해결할 수 있습니까?

답변

0

아니요, 수신 데이터를 수신했습니다. 전에 변수를 nil로 설정 했으므로 receivedData로 보낸 모든 메시지는 너바나로 이동합니다.

또한 connectionDidFinishLoading이 호출되지 않는 경우를 처리하는 것을 잊지 마세요.이 때문에 다른 곳에서도 릴리스해야합니다.