Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection leaking on multi-threaded apps?



If you can't find a solution for the leak, I would suggest just using NSURLConnection directly yourself then. From your main thread use its asynchronous methods to get the data, and then init an XML document with that.

Mike.

On 4 Mar 2007, at 23:51, Paul Borokhov wrote:

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:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev% 40mikeabdullah.net


This email sent to email@hidden

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >NSURLConnection leaking on multi-threaded apps? (From: Paul Borokhov <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.