title: memory growth when using blocks & Path's FastImageCache
body: <p>I am using Path's excellent FastImageCache library and am running into a retain problem.</p>
  
  <p>Specifically, when trying to provide UIImages (downloaded from a server) to the image cache. The images, when handed to the completion block, seems to remain retained. ARC is not releasing is.</p>
  
  <p>When dealing with a very large number of large images, this leads to a dramatic memory growth.</p>
  
  <pre><code>- (void)imageCache:(FICImageCache *)imageCache wantsSourceImageForEntity:(id&lt;FICEntity&gt;)entity withFormatName:(NSString*)formatName completionBlock:(FICImageRequestCompletionBlock)completionBlock
  {
      ...
      NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
                                                returningResponse:&amp;response
                                                            error:&amp;error];
      UIImage* image = [[UIImage alloc] initWithData:data];
      completionBlock(image); // &lt;-----
      ...
  }
  </code></pre>
  
  <p>I verified that not calling the completion block with the image, does not lead to the memory growth.</p>
  
  <p>Also, not using the image in the drawing block itself, also avoids the memory growth. So i assume this is indeed related to the image being retained.</p>
  
  <pre><code>- (FICEntityImageDrawingBlock)drawingBlockForImage:(UIImage*)image withFormatName:(NSString*)formatName
  {
      FICEntityImageDrawingBlock drawingBlock = ^(CGContextRef contextRef, CGSize contextSize) {
          CGRect contextBounds = CGRectZero;
          contextBounds.size = contextSize;
          CGContextClearRect(contextRef, contextBounds);
          CGContextSetInterpolationQuality(contextRef, kCGInterpolationMedium);
          UIGraphicsPushContext(contextRef);
          [image drawInRect:contextBounds]; // &lt;---- 
          UIGraphicsPopContext();
      };
  
      return drawingBlock;
  }
  </code></pre>
  
  <p>How can i avoid the image being retained or how can i force it to be released? I tried setting it to nil and adding a @autoreleasepool but that didn't help.</p>
  
  <pre><code>@autoreleasepool {
          NSData * data = [NSURLConnection sendSynchronousRequest:urlRequest
                                                returningResponse:&amp;response
                                                            error:&amp;error];
  
          UIImage* image = [[UIImage alloc] initWithData:data];
          completionBlock(image);
          image = nil;
          data = nil;
  
          [[NSURLCache sharedURLCache] removeAllCachedResponses];
      }
  </code></pre>
  
  <p>Thanks for the help.</p>
  
  <p><strong>UPDATE 3/18/2014</strong><br>
  <em>Note: this does NOT appear to be an issue in the simulator, only on the device.</em></p>