title: Memory Leak with ARC
body: <pre><code>+(void)setup {
      UIImage* spriteSheet = [UIImage imageNamed:@"mySpriteSheet.png"];
      CGRect rect;
      animation = [NSMutableArray arrayWithCapacity:numberOfFramesInSpriteSheet];
      int frameCount = 0;
  
      for (int row = 0; row &lt; numberFrameRowsInSpriteSheet; row++) {
          for (int col = 0; col &lt; numberFrameColsInSpriteSheet; col++) {
              frameCount++;
              if (frameCount &lt;= numberOfFramesInSpriteSheet) {
                  rect = CGRectMake(col*frameHeight, row*frameWidth, frameHeight, frameWidth);
                  [animation addObject:[UIImage imageWithCGImage:CGImageCreateWithImageInRect(spriteSheet.CGImage, rect)] ];
              }
           }
      }
  }
  </code></pre>
  
  <p>Compiled the above code with ARC enabled. The Analyze tool reports a possible memory leak since imageWithCGImage:: returns UIImage with count +1, then reference is lost. Leaks Instrument reports no memory leaks at all. Whats going on here? </p>
  
  <p>Furthermore, since ARC prohibits use of manually using <code>release</code> ect, how does one fix the leak?</p>
  
  <p>Thanks to anyone who can offer any advice.</p>