アップデート:
非常に単純なダウンロード コードを作成しました。
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でそれを書き、他のすべてのコードをコメントアウトしました。メモリ使用量は変わらず、増加しています。
新しいプロジェクトを作成し、新しいプロジェクトにまったく同じコードを書きました。そして、メモリ使用量は次のとおりです。
どっちがいい。しかし、実際のプロジェクトではなぜ違うのかわかりませんか?