获取的图像时,我有我的iOS应用获取一张图像的时间越来越多,并显示在屏幕(非常像幻灯片)上。我遇到低内存的情况。在运行Allocations时查看仪器,我发现内存在不断增长。调用树显示正在使用大量的内存,但没有一行是我的代码,我不是在调试这些情况下,知道如何读它足够的经验。内存与AFNetworking
下面是我与获取图像的代码:
- (void)fetchLargeImage:(void (^)(UIImage *))completion
{
// image doesn't exist yet, fetch it now
NSURL *resourceURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://path_to_image/%@", @"image_name.jpg"];
NSURLRequest *request = [NSURLRequest requestWithURL:resourceURL];
AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:request imageProcessingBlock:^UIImage *(UIImage *image) {
return image;
} success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image) {
completion(image);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error) {
// image wasn't loaded
}];
[operation start];
}
由于图像显示,我保存最后10幅图像,因为用户可以刷卡向后回顾前面所示图片。在我的清理方法中,我NIL出在图像视图和ImageView的自身的图像,并且从该阵列中删除。所以我不确定还有什么能够保持它,并导致内存继续增长。我在这里错过了什么?
这听起来很有前途,但我没有看到任何效果运行的仪器。虽然谢谢! – Stephen 2013-02-12 05:23:21