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 (Cocoa-dev@lists.apple.com)

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:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to