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

更新:

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

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]; } 

我写在我的项目viewDidLoad注释掉所有其他的代码。 内存使用情况仍然相同,并在不断增加:

在这里输入图像说明

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

在这里输入图像说明

哪个好。 但是我不明白为什么它在真实的项目中是不同的呢?

我想你打开僵尸模式。 产品 – >scheme – >编辑scheme
取消选中[启用僵尸对象]

在这里输入图像说明

这很尴尬。 我创build了一个新的项目,并复制相同的代码,它没有内存警告。 下载操作不影响内存。 我不明白这个问题。 也许是因为项目设置。

同样发生在我身上。 禁用僵尸对象为我工作。

尝试使用NSOperationQueue手动下载

过来