On Oct 10, 2014, at 11:00 AM, Kyle Sluder <k...@ksluder.com> wrote:

>> On Oct 10, 2014, at 6:42 AM, Steve Mills <sjmi...@mac.com> wrote:
>> 
>> I've only created one NSOperationQueue and added many NSInvocationOperation 
>> to it.
> 
> NSOperationQueue works by dispatching your blocks to the global async GCD 
> queue. If you send a thousand blocks to be async processed at once, GCD will 
> keep spinning up threads to try to service them until it exhausts the thread 
> limit and your process deadlocks.
> 
> It sucks, but you have to be judicious in the number of blocks you submit to 
> the global queue. Set a max operation count on your NSOperationQueue.

I ran into the same problem in my first foray into using NSOperationQueue.  
When adding several hundred block operations to the queue, it pretty much 
choked trying to run all several hundred at once.  Now, when I create an 
NSOperationQueue for what could be more than a few operations, I always use:

myQueue.maxConcurrentOperationCount = [[NSProcessInfo processInfo] 
processorCount];

The processorCount is actually logical core count, so on my 4-core i7 it 
returns 8. 

Jim


_______________________________________________

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