NSURLConnection leaking on multi-threaded apps?
NSURLConnection leaking on multi-threaded apps?
- Subject: NSURLConnection leaking on multi-threaded apps?
- From: Paul Borokhov <email@hidden>
- Date: Sun, 4 Mar 2007 15:51:06 -0800
So, as a follow-up to my previous threads discussion, which I do want to keep on-topic, it appears that NSURLConnection leaks whenever it's called inside a method that's been detached from the main thread. Namely, I tested my application with threading and without, and the thread-less version has no leaks. Just to reiterate, I never actually call the NSURLConnection methods directly, I DO have autorelease pools set up properly, and there is NOTHING else that is leaking (apart from the NSUC-associated classes), even though I do create (and manage to properly discard) a lot of other data, including XML documents, strings, etc. I'm guessing that the reason NSURLConnection gets called at all is because I call NSXMLDocument initWithContentsOfURL:options:error: to get data, and that method uses NSURLConnection internally? (if not, I'm really lost because, again, I never actually call NSURLConnection myself).
I found this page online which seems to illustrate this problem more concisely (though it calls NSUC directly), if I'm reading the code correctly: http://paste.lisp.org/display/21630 . There, a loop performs 100000 NSURLConnections, each on its own thread. When the program is run through ObjectAlloc, each instance of Connection, Request, and all other associated data is never released. Since the data requested is not that great, the leak isn't as noticeable, but if you're retrieving a significant amount of data each time, the numbers can add up quickly.
Can someone confirm for me that this is actually a bug and not something I can solve on my own, or am I really just missing something?
Paul
P.S. The unreleased NSURLConnections are also accompanied (among other things) by unreleased NSLocks and immutable CFStrings. The NSLocks, if I'm understanding things correctly, are coming from synchronous requests sent by NSURLConnection, which lock the current thread.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden