QTimer makes the application slow.
-
I made one application having one mainwindow and 7 dialogs.
Each dialog has some tasks to update data from oracle DB.
So I used QTimer on mainwindow such thatQTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), mode2, SLOT(mode_update())); connect(timer, SIGNAL(timeout()), mode3, SLOT(mode_update())); connect(timer, SIGNAL(timeout()), mode4, SLOT(mode_update())); connect(timer, SIGNAL(timeout()), mode5, SLOT(mode_update())); connect(timer, SIGNAL(timeout()), mode6, SLOT(mode_update())); connect(timer, SIGNAL(timeout()), mode7, SLOT(mode_update())); timer->start(1000); QTimer *timer10 = new QTimer(this); connect(timer10, SIGNAL(timeout()), mode4, SLOT(mode_update10())); connect(timer10, SIGNAL(timeout()), mode5, SLOT(mode_update10())); connect(timer10, SIGNAL(timeout()), mode6, SLOT(mode_update10())); timer->start(10000);
First, it works well, but, after 1 hour its update cycle delays to 15 second.
Is there any way to reduce delay? -
Hi
The delays comes from something.Often is leaking memory .
So you should find out why it gets slow.
There is no reason using timers should become slow over time
so its something else. -
Btw, maybe source of delay is data base connection. I suggest using a stopwatch to record total time spend for each slot. If time doesn't change over time but still you observe the delay, then use valgrind to check memory leaks.
http://doc.qt.io/qt-4.8/qt-demos-spectrum-3rdparty-fftreal-stopwatch-stopwatch-cpp.html