• 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
NSOperationQueue question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSOperationQueue question


  • Subject: NSOperationQueue question
  • From: Tim Murison <email@hidden>
  • Date: Fri, 07 Aug 2009 15:06:16 -0400
  • Thread-topic: NSOperationQueue question

Hi Cocoa gurus,

I'm running on Leopard 10.5.7 (and Snow Leopard, but that's a different
problem!) and have been seeing some strange behaviour with NSOperationQueue.
I know about the crash in 10.5.6 and earlier, but this doesn't seem to be
related to that crash.

The code is below and was compiled with objc-gc-only. If I run the program,
despite the setMaxConcurrentOperationCount:4, it will use 65 threads. Also
it will leak memory at ~1Mb/sec.

#import <Cocoa/Cocoa.h>
#include <libkern/OSAtomic.h>

volatile int64_t globalCounter;

@interface Operation : NSOperation
+ (Operation*) operation;
@end

@implementation Operation
+ (Operation*) operation
{
        return [[Operation alloc] init];
}

- (void) main
{
        OSAtomicIncrement64(&globalCounter);
}
@end

int main(int argc, char **argv)
{
        NSOperationQueue *queue = [[NSOperationQueue alloc] init];

        [queue setMaxConcurrentOperationCount:4];

        while (1) {
                int64_t tmp;

                [queue addOperation:[Operation operation]];
                tmp = globalCounter;

                if (tmp % 100 == 0) {
                        [[NSGarbageCollector defaultCollector]
collectExhaustively];
                        printf("Counter: %lld\n", tmp);
                }
        }
}



***********************************************************************

This e-mail and its attachments are confidential, legally privileged, may be subject to copyright and sent solely for the attention of the addressee(s).
Any unauthorized use or disclosure is prohibited. Statements and opinions expressed in this e-mail may not represent those of Radialpoint.

Le contenu de ce courriel est confidentiel, privilégié et peut être soumis à des droits d'auteur. Il est envoyé à l'intention exclusive de son ou de ses
destinataires. Il est interdit de l'utiliser ou de le divulguer sans autorisation. Les opinions exprimées dans le présent courriel peuvent diverger de celles de Radialpoint.
_______________________________________________

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

  • Follow-Ups:
    • Re: NSOperationQueue question
      • From: Franck Zoccolo <email@hidden>
    • Re: NSOperationQueue question
      • From: Quincey Morris <email@hidden>
  • Prev by Date: Re: Two right buttons on UINavigationBar?
  • Next by Date: Re: NSOperationQueue question
  • Previous by thread: Re: [NSObject setValue:forUndefinedKey:] no longer requires explicit KVC notifications?
  • Next by thread: Re: NSOperationQueue question
  • Index(es):
    • Date
    • Thread