• 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: James DiPalma <email@hidden>
  • Date: Sat, 26 Oct 2002 16:54:49 -0700

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.

I don't understand Douglas Davidson's suggestion:

it sounds rather like polling. It would be better, if possible, to use a run loop source instead.

Documentation for NSRunLoop says, "An NSRunLoop processes input for sources such as mouse and keyboard events from the window system, NSPorts, NSTimers, and NSConnections."


-jim
_______________________________________________
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.

  • Follow-Ups:
    • Re: NSTimer "takes over" CPU everytime it repeats?
      • From: Nat! <email@hidden>
References: 
 >Re: NSTimer "takes over" CPU everytime it repeats? (From: Cameron Hayne <email@hidden>)

  • Prev by Date: Re: Window Controller not being released.
  • Next by Date: PlugIn behavior: Strange but Extremely Sexy!
  • Previous by thread: Re: NSTimer "takes over" CPU everytime it repeats?
  • Next by thread: Re: NSTimer "takes over" CPU everytime it repeats?
  • Index(es):
    • Date
    • Thread