• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSURLConnection leaking on multi-threaded apps?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSURLConnection leaking on multi-threaded apps?


  • Subject: Re: NSURLConnection leaking on multi-threaded apps?
  • From: j o a r <email@hidden>
  • Date: Mon, 5 Mar 2007 10:18:14 +0100


On 5 mar 2007, at 00.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 don't know what the official word for thread safety is for these classes. This page doesn't mention them as being either thread safe, or unsafe:


<http://developer.apple.com/documentation/Cocoa/Conceptual/ Multithreading/articles/CocoaSafety.html>

When there is no documentation, you should assume that it's only OK to use the class from the main thread.

I've seen crashes when trying to use NSURLConnection from background threads. Each NSURLConnection instance was only ever used from one particular thread, but it's my guess that they share some common resource - a cache or something like that - that triggered my problem. That said, I'm not 100% sure that it was because of the threading, and not some stupid mistake of mine...

I suggest you file a bug report / enhancement request to ask Apple to update the documentation regarding thread safety for these classes.

j o a r


Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

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

  • Prev by Date: Cocoa-dev Digest, Vol 4, Issue 203
  • Next by Date: Re: shortcut for selecting in NSPopUpButton
  • Previous by thread: NSURLConnection leaking on multi-threaded apps?
  • Next by thread: Re: NSURLConnection leaking on multi-threaded apps?
  • Index(es):
    • Date
    • Thread