继续增加内存分配

时间:2014-09-19 07:15:09

标签: ios objective-c memory-management memory-leaks malloc

在我的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;

}

App降低其性能。我该如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

你有发布的receivedData。您之前已将变量设置为nil,因此发送到receivedData的任何消息都会转到nirvana。

另外不要忘记处理从未调用connectionDidFinishLoading的情况,因此你必须在其他地方发布它。