Cocoa App. (MAC) is very slow

239 views Asked by At

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];
1

There are 1 answers

0
Parag Bafna On

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.