问题
Update:
I wrote a very simple download code:
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];
}
I wrote it in my projects viewDidLoad commenting out all other codes. Memory usage is still the same and increasing:

I created a new project, and I wrote exactly the same code in the new project. And the memory usage is:

Which is good. But I don't understand why it is different in the real project?
回答1:
I guess you open the zombie mode.
Product -> Scheme -> Edit Scheme
Uncheck the opition [Enable Zombie Object]

回答2:
This is awkward. I created a new project, and copy the same code, and it is working without memory warning. Download operation doesn't effect the memory. I didn't understand the problem. Maybe because of the project settings.
回答3:
Same happened to me. Disable zombies object worked for me.
回答4:
Try downloading manually by using NSOperationQueue
Get here
来源:https://stackoverflow.com/questions/19159932/memory-warning-while-downloading-file-with-afnetworking