Re: NSURLConnection leaking on multi-threaded apps?
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