2014-09-19 90 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

你有不是發佈receivedData。您之前已將該變量設置爲零,因此發送到receivedData的所有消息都轉到涅v。

也不要忘記處理connectionDidFinishLoading永遠不會被調用的情況下,你必須在其他地方釋放它,因爲這一點。