0
基本上,当文件下载完成时,内存中的某些内容永远无法释放。下面是导致这个问题的代码的一个简单例子,内存高达50mb左右,它只是坐在那里,永远不会被释放(见下面的截图)。对发生什么事有任何想法?使用AFNetworking下载时出现泄漏
-(void)download {
NSString* urlString = @"http://download.thinkbroadband.com/50MB.zip";
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]];
AFHTTPRequestOperation* operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
[operation setDownloadProgressBlock:^(NSUInteger bytesRead, long long totalBytesRead, long long totalBytesExpectedToRead) {
NSLog(@"%lldmb of %lldmb downloaded", totalBytesRead/1024/1024, totalBytesExpectedToRead/1024/1024);
}];
[operation setCompletionBlockWithSuccess:^(__weak AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Download completed.");
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error.localizedDescription);
}];
[operation start];
}
下载之前:
下载后:
谢谢!我会尽快给这个镜头=)。 – Carlo 2014-12-06 19:03:50
有趣的是,它并没有为我工作。内存开始时约11mb,下载完成后5分钟,它仍然在42.8mb ...我也使用AFNetworking 2.5.0和iOS 8.1。 – Carlo 2014-12-06 19:09:14
您确定您处于发布模式?我通过仪器进行了测试,默认情况下它们以发布模式构建。 – 2014-12-08 03:41:32