title: Help me understand leaks on this code:
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/7431777/how-to-release-an-object-declared-into-a-method-and-passed-to-another-method">How to release an object declared into a method and passed to another method?</a>  </p>
  </blockquote>
  
  
  
  <p>Can you help me fix leaks in this code:</p>
  
  <pre><code>- (void)connectionDidFinishLoading:(NSURLConnection *)connection
  {
      UIImage *payload = [[UIImage alloc] initWithData:self.activeDownload];
      UIImage *picture = [[UIImage alloc] init];
      if (payload.size.width != kAppIconHeight &amp;&amp; payload.size.height != kAppIconHeight)
      {
          CGSize itemSize = CGSizeMake(kAppIconHeight, kAppIconHeight);
          UIGraphicsBeginImageContext(itemSize);
          CGRect imageRect = CGRectMake(0.0, 0.0, itemSize.width, itemSize.height);
          [payload drawInRect:imageRect];
          picture = UIGraphicsGetImageFromCurrentImageContext();
          UIGraphicsEndImageContext();
      }
      else
      {
          picture = payload;
      }
  
      self.activeDownload = nil;
      [payload release];
  
      self.imageConnection = nil;
  
      [delegate ThumbDidLoad:self.indexPathInTableView Image:[picture autorelease]];
  }
  </code></pre>
  
  <p>Thx for helping,</p>
  
  <p>Stephane</p>