2012-04-10 10 views
0

私はちょうどASIHTTPからAFNetworkingライブラリに移動しました。 Olivier PoitreyとPeter SteinbergのSDURLCacheライブラリも使用しています。私は私のアプリケーションで使うつもりのすべてのイメージをキャッシュしたい。AFNetworkingのメモリリークIOSのキャッシュイメージ

NSOperationQueue *queue = [[NSOperationQueue alloc] init]; 
     for(NSURLRequest *imageRequest in imageRequestArray){ 
      AFURLConnectionOperation *operation2 = [[[AFURLConnectionOperation alloc] initWithRequest:imageRequest] autorelease]; 
      [queue addOperation: operation2]; 
      [operation2 waitUntilFinished]; 
} 

そして、私は、画像を表示する必要があるとき、私はそれぞれのイメージのためにこれをやっている:これらのために、私はこれを試してみましたしばらく

NSURL *url = [NSURL URLWithString:[cat imagePath]]; 
     NSURLRequest *imageRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0]; 


     AFImageRequestOperation *operation = [AFImageRequestOperation imageRequestOperationWithRequest:imageRequest 
                        imageProcessingBlock:nil 
                          cacheName:@"nscache" 
                           success:^(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image){ 
                            //NSData *responseData = [request responseData]; 
                            imageView.alpha = 0.0; 
                            [imageView setImage:image forState:UIControlStateNormal]; 
                            [UIView beginAnimations:@"ToggleViews" context:nil]; 
                            [UIView setAnimationDuration:1.0];     
                            imageView.alpha = 1.0; 
                            [UIView commitAnimations]; 
                           } 
                           failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error){} 
               ]; 
     [operation start]; 

、アプリケーションがメモリの警告を与え、その後、シャットダウンします。そのために、私は次のようでした:

- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 
[[NSURLCache sharedURLCache] removeAllCachedResponses]; 
NSLog(@"Memory Warning..."); 
} 

これは、キャッシュをクリアします(私は何ではない何をすべきか)が、しばらくした後、アプリケーションが再び閉じます。

どうすればよいですか?

+0

私は同様の問題が生じています信じて、私は楽器をチェックすると私のアプリのメモリ使用量は、それがその後、200megsについて当たるまでいっていますメモリ警告のためにアプリが終了しました。問題を追跡しようとしていますが、リークはありません –

答えて

関連する問題