-2

I am using a timer based application, where i am running 3 timers continuously in main run loop, so that the timer will continuously runs in case of any UI updates. But after some time (Approx 1 hour), my application hangs, not event the buttons etc are pressed.It tooks at least 10-15 seconds to respond.

I want to know what are the lagging causes in MAC cocoa application. I am working on a timer based app. so i need multiple timers to run. I invalidates also, when of no use. But it still didn't helps me out.

Please guide for any performance debug too for mac, so that i can check where my code is creating issue etc?

Code:

NSRunLoop *runloop = [NSRunLoop currentRunLoop]; 
updateServerTimeTimer = [NSTimer timerWithTimeInterval:1.0 
                                                target:self
                                              selector:@selector(updateServerTime)
                                              userInfo:nil 
                                               repeats:YES]; 
[runloop addTimer:updateServerTimeTimer forMode:NSRunLoopCommonModes];
mttrb
  • 8,297
  • 3
  • 35
  • 57
york
  • 149
  • 1
  • 11
  • NSRunLoop *runloop = [NSRunLoop currentRunLoop]; updateServerTimeTimer = [NSTimer timerWithTimeInterval:1.0 target:self selector:@selector(updateServerTime) userInfo:nil repeats:YES]; [runloop addTimer:updateServerTimeTimer forMode:NSRunLoopCommonModes]; – york Oct 19 '12 at 07:02
  • i think your problem is NSRunLoopCommonModes. why you want to use NSRunLoopCommonModes? – Parag Bafna Oct 19 '12 at 07:18

1 Answers1

0

Your problem is NSRunLoopCommonModes .use scheduledTimerWithTimeInterval:target:selector:userInfo:repeats: method, it will schedule NSTimer in NSDefaultRunLoopMode. If UI is updating, your application will get other events later. Take a look at this post.

Community
  • 1
  • 1
Parag Bafna
  • 22,812
  • 8
  • 71
  • 144