Wednesday, October 28, 2026
HomeiOS Developmentios - what number of operations NSOperationQueue can cache

ios – what number of operations NSOperationQueue can cache

[ad_1]

I created a NSOperationQueue and set the maxConcurrentOperationCount property to 2.
If I create 2 operations that don’t cease, once I proceed so as to add operations to it, the NSOperationQueue will cache these duties, so what’s the most variety of operations that may be cached by the NSOperationQueue, Will it trigger a reminiscence surge?

    NSOperationQueue *queue = [[NSOperationQueue alloc] init];
    queue.maxConcurrentOperationCount = 2;
    
    [queue addOperationWithBlock:^{
        while (YES) {
            NSLog(@"thread1 : %@",[NSThread currentThread]);
        }
    }];
    
    [queue addOperationWithBlock:^{
        while (YES) {
            NSLog(@"thread2 : %@",[NSThread currentThread]);
        }
    }];
  
    // this operation will wait 
    [queue addOperationWithBlock:^{
        while (YES) {
            NSLog(@"thread3 : %@",[NSThread currentThread]);
        }
    }];

above is my code, third operation won’t ever run,
from what I perceive, the queue will save these duties, for those who preserve including operations to it, the reminiscence will preserve going up,
Will NSOperationQueue deal with this case internally?

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments