• 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: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"


  • Subject: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • From: David Duncan <email@hidden>
  • Date: Tue, 10 Jul 2012 10:11:47 -0700

On Jul 10, 2012, at 12:56 AM, Jonathan Taylor wrote:

>>> In practice, NSOperationQueue probably releases the block when it's done with it
>>
>> I'm curious about your use of the word "probably" here. Can you explain?
>
> This is probably not what the OP had in mind, but I might mention that I've seen situations where autoreleases associated with NSOperationQueues and GCD queues have still been outstanding five minutes later under conditions of extremely high load. (My suspicion is that a mouse click or other user event causes these to be carried out, but I didn't test that one systematically).

GCD creates autorelease pools of "last resort" - they are basically only there to prevent what would otherwise be unavoidable leaks if they were not present. Because the threads that own these autorelease pools have an undefined lifetime, the lifetime of these autorelease pools can similarly be exceptionally long.

Basic rule of thumb thus is to create your own autorelease pool for such blocks or operations to ensure that your autoreleases are carried out in a timely manner. This is not unlike how you create your own autorelease pools when creating a new NSThread.
--
David Duncan


_______________________________________________

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: 
 >Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle" (From: Jonathan Taylor <email@hidden>)

  • Prev by Date: Re: Bottom-edge constraint not enforced in IB but is in runtime?
  • Next by Date: Re: Bottom-edge constraint not enforced in IB but is in runtime?
  • Previous by thread: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • Next by thread: Re: "Capturing 'self' strongly in this block is likely to lead to a retain cycle"
  • Index(es):
    • Date
    • Thread