Reputation: 5774
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?
Upvotes: 2
Views: 853
Reputation: 163
I guess you open the zombie mode.
Product -> Scheme -> Edit Scheme
Uncheck the opition [Enable Zombie Object]
Upvotes: 5
Reputation: 5774
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.
Upvotes: 1