• 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 cancel] doesn't release its delegate?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: -[NSURLConnection cancel] doesn't release its delegate?


  • Subject: Re: -[NSURLConnection cancel] doesn't release its delegate?
  • From: Keary Suska <email@hidden>
  • Date: Thu, 18 Dec 2008 11:30:53 -0700


On Dec 18, 2008, at 10:57 AM, Jonathan del Strother wrote:

Heya,
I ran into a memory leak recently that I finally managed to track down
to NSURLConnection retaining its delegate.

It appears that cancelling an NSURLConnection won't actually release
its delegate until the next time around the run loop.  Normally this
is fine, but I was running on a separate thread with its own run loop,
and I was just cancelling the connection & immediately exiting the
thread.

Is this a bug, undocumented feature, or am I missing something?


Risking yet another foot-in-mouth syndrome, I will comment.

I would file a radar both on NSURLConnection and the documentation. An object shouldn't be retaining its delegate except with good reason, and that reason (or simply the fact of the retention) should be well documented. Otherwise you could get a nasty retain cycle.

Anyway, it looks like NSURLConnection is releasing the delegate using a performSelector:withObject:afterDelay: or similar method. Running the run loop as you remark in the code is the only way I know of to make sure the delegate is released before the thread exits.

HTH,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please 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 cancel] doesn't release its delegate? (From: "Jonathan del Strother" <email@hidden>)

  • Prev by Date: Re: Thread ID in crash log
  • Next by Date: Re: Age Old Question: How Do You Set __MyCompanyName__
  • Previous by thread: -[NSURLConnection cancel] doesn't release its delegate?
  • Next by thread: Re: -[NSURLConnection cancel] doesn't release its delegate?
  • Index(es):
    • Date
    • Thread