使用AFNetworking下载文件时出现内存警告

Bur*_*rak 2 memory-leaks memory-management ios afnetworking afnetworking-2

更新:

我写了一个非常简单的下载代码:

NSArray       *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString  *documentsDirectory = [paths objectAtIndex:0];

NSURLRequest* request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"http://xxxx.s3.amazonaws.com/products/ipad/xxxx.mp4"]];
for(int i=0; i<4; i++){
    NSString  *filePath = [NSString stringWithFormat:@"%@/%@", documentsDirectory,[NSString stringWithFormat:@"xxxx%d.mp4",i]];
    AFDownloadRequestOperation* operation = [[AFDownloadRequestOperation alloc] initWithRequest:request targetPath:filePath shouldResume:YES];
    operation.outputStream = [NSOutputStream outputStreamToFileAtPath:filePath append:NO];
    [operation setShouldOverwrite:YES];
    [operation setProgressiveDownloadProgressBlock:^(AFDownloadRequestOperation *operation, NSInteger bytesRead, long long totalBytesRead, long long totalBytesExpected, long long totalBytesReadForFile, long long totalBytesExpectedToReadForFile) {
        NSLog(@"%f", ( totalBytesRead / (float)totalBytesExpected));
    }];
    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"finished");
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(error.description);
    }];
    [[NSOperationQueue mainQueue] addOperation:operation];
}
Run Code Online (Sandbox Code Playgroud)

我在我的项目viewDidLoad中写下了它,注释掉了所有其他代码.内存使用率仍然相同且不断增加:

在此输入图像描述

我创建了一个新项目,并在新项目中编写了完全相同的代码.内存使用情况是:

在此输入图像描述

这很好.但我不明白为什么它在真实项目中有所不同?

sno*_*lax 5

我想你打开了僵尸模式.产品 - > Scheme - > Edit Scheme
取消选中opition [Enable Zombie Object]

在此输入图像描述