title: Memory leak in AFNetworking Cache images in IOS
body: <p>I just moved from ASIHTTP to AFNetworking library. I am also using SDURLCache library from Olivier Poitrey and Peter Steinberg. I want to cache all the images that I gonna use in my application. For these, I tried this:</p>
  
  <pre><code>NSOperationQueue *queue = [[NSOperationQueue alloc] init];
          for(NSURLRequest *imageRequest in imageRequestArray){
              AFURLConnectionOperation *operation2 = [[[AFURLConnectionOperation alloc] initWithRequest:imageRequest] autorelease];
              [queue addOperation: operation2];
              [operation2 waitUntilFinished];
  }
  </code></pre>
  
  <p>And when I need to show images, I am doing this for each image:</p>
  
  <pre><code>  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];
  </code></pre>
  
  <p>After a while, application gives memory warning, then shuts down. For that, I did the following:</p>
  
  <pre><code>- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
  [[NSURLCache sharedURLCache] removeAllCachedResponses];
  NSLog(@"Memory Warning...");
  }
  </code></pre>
  
  <p>It clears the cache(what I don't what) but after a while, application closes again.</p>
  
  <p>What should I do for that? </p>