Instrument reports leak for this simple use of NSURLConnection:
#import <Foundation/Foundation.h>
int main (int argc, char ** argv)
{
NSAutoreleasePool *pool = [NSAutoreleasePool new];
NSURLRequest *theRequest = [NSURLRequest
requestWithURL:[NSURL URLWithString:@"https://gmail.com/"]
cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
timeoutInterval:60.0];
[NSURLConnection connectionWithRequest:theRequest delegate:nil];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:5]];
[pool drain];
[NSThread sleepForTimeInterval:10]; // wait for Instruments to check
}
Leak stack trace:
0 CoreFoundation __CFBasicHashRehash
1 CoreFoundation CFDictionaryCreate
2 CFNetwork _getConnectionInfoForProxy
3 CFNetwork HTTPProtocol::createStream()
4 CFNetwork HTTPProtocol::createAndOpenStream()
5 CFNetwork executionContextPerform(void*)
6 CoreFoundation __CFRunLoopDoSources0
7 CoreFoundation __CFRunLoopRun
8 CoreFoundation CFRunLoopRunSpecific
9 CoreFoundation CFRunLoopRunInMode
10 Foundation +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:]
11 Foundation -[NSThread main]
12 Foundation __NSThread__main__
13 libSystem.B.dylib _pthread_start
14 libSystem.B.dylib thread_start
It doesn't leak if the URL is just normal http and it doesn't redirect to a https site.
How do I fix the leak?
I'm using Snow Leopard and I have proxies on for both http and https.