• 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: John Mikros <email@hidden>
  • Date: Tue, 13 Mar 2007 14:07:36 -0700

I don't know if this will help you, but our app was leaking memory in NSURLConnection as well. I didn't realize it could be related to creating the NSURLConnection on a secondary thread -- that may very well be the case.

In any event, we found that the leak went away if we set the capacity of the URL cache to zero.

	[[NSURLCache sharedURLCache] setMemoryCapacity:0];
	[[NSURLCache sharedURLCache] setDiskCapacity:0];

In our case, we don't want any of the data cached anyway, so this made sense.

-john

On Mar 11, 2007, at 9:12 AM, Matt Neuburg wrote:

On Sun, 4 Mar 2007 15:51:06 -0800, Paul Borokhov <email@hidden> said:
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?

This sounds like a variant of the NSURLConnection bug that causes a sporadic
crash when loading Core Data data from an XML store. The
NSPersistentStoreCoordinator calls NSXMLDocument
initWithContentsOfURL:options:error: which calls NSURLConnection and things
rapidly go south because of threading (and it's all Apple's code, so doing
something about it is quite tricky).


So, to sum up, yes, it's known that there are memory-management problems
with NSURLConnection and threads, and Apple's own code falls prey to these
problems. m.


--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



_______________________________________________

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:
40blizzard.com


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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSURLConnection leaking on multi-threaded apps?
      • From: Paul Borokhov <email@hidden>
References: 
 >Re: NSURLConnection leaking on multi-threaded apps? (From: Matt Neuburg <email@hidden>)

  • Prev by Date: Re: Sharing a content view between two NSWindows
  • Next by Date: Re: Adding AppleScript support to a Core Data application
  • Previous by thread: Re: NSURLConnection leaking on multi-threaded apps?
  • Next by thread: Re: NSURLConnection leaking on multi-threaded apps?
  • Index(es):
    • Date
    • Thread