title: memory leak with NSMutableData
body: <p>I have a class for connecting with httprequests. I am getting a memory leak for "NSMutableData" altho I am releasing it in "didFailWithError" and in "connectionDidFinishLoading" of the connection object:</p>
  
  <pre><code>- (BOOL)startRequestForURL:(NSURL*)url {
  
  [url retain];
  
  
  NSMutableURLRequest* urlRequest = [[NSMutableURLRequest alloc] initWithURL:url];
  // cache &amp; policy stuff here
  [[NSURLCache sharedURLCache] removeAllCachedResponses];
  [urlRequest setHTTPMethod:@"POST"];
  [urlRequest setHTTPShouldHandleCookies:YES];
  NSURLConnection* connectionResponse = [[[NSURLConnection alloc] initWithRequest:urlRequest delegate:self] autorelease];
  if (!connectionResponse)
  {
      // handle error
      return NO;
  } else {
      receivedData = [[NSMutableData data] retain]; // memory leak here!!!
  }
  
  [url release];
  
  [urlRequest release];
  
  
  return YES;}
  
  - (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error {
  UIAlertView *alert =
  [[[UIAlertView alloc]
    initWithTitle:NSLocalizedString(@"Connection problem", nil)
    message:NSLocalizedString(@"A connection problem detected. Please check your internet connection and try again.",nil)
  
    delegate:self
    cancelButtonTitle:NSLocalizedString(@"OK", nil)
    otherButtonTitles:nil, nil]
   autorelease];
  [alert show];
  
  [connectionDelegate performSelector:failedAction withObject:error];
  [receivedData release];}
  
  - (void)connectionDidFinishLoading:(NSURLConnection*)connection {
  [connectionDelegate performSelector:succeededAction withObject:receivedData];
  [receivedData release];}
  </code></pre>