• 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: NSTimer "takes over" CPU everytime it repeats?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimer "takes over" CPU everytime it repeats?


  • Subject: Re: NSTimer "takes over" CPU everytime it repeats?
  • From: Nat! <email@hidden>
  • Date: Sun, 27 Oct 2002 11:48:26 +0100

Am Sonntag, 27.10.02 um 01:54 Uhr schrieb James DiPalma:

From: Cameron Hayne <email@hidden>

And by the way, it is slightly misleading to say that your "timer takes over
the CPU" - it isn't the timer but rather the code that is executed when the
timer fires that is taking over the CPU.

If you look at Hisaoki's timer, it might just be his timer that takes over the CPU.

From: Hisaoki Nishida <email@hidden>

selectTimer = [[NSTimer scheduledTimerWithTimeInterval:0.0
target:self selector:@selector(run)
userInfo:nil repeats:YES] retain];

I created an NSTimer just like this and called a method that does nothing and my sample app doing nothing but fire this timer in a background thread took over 50% of my CPU. Ondra's suggestion of adding a small time interval might help.

But what do you expect ? I would assume that the timer is firing incessantly, and someone needs to execute the NSTimer and the "run" code. That's going to be the CPU.... It's not really much different from writing for(;;) [self run];


Ciao
Nat!
------------------------------------------------------
I was hoping that the people of the world might be
united by something more interesting, like drugs or an
armed struggle against the undead. Unfortunately my
father's team won, so computers it is. -- Sedaris
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSTimer "takes over" CPU everytime it repeats? (From: James DiPalma <email@hidden>)

  • Prev by Date: Re: Internet Protocol Helper Applications
  • Next by Date: Focus ring around NSTextField
  • Previous by thread: Re: NSTimer "takes over" CPU everytime it repeats?
  • Next by thread: retrieving your IP address
  • Index(es):
    • Date
    • Thread