Solved paint/event loop slowing down.
-
In my Qt5 Widgets (windows) application I have a long running process that opens a window, draws images into it which are captured off a camera, closes the window and then repeats..
If I put elapsedTimer's within my various paintEvent handlers and log the results, I can see that the actual execution time of my paintEvent handlers isn't slowing down (they all tend to be 2-3ms) and I've verified that the frame-rate of the external camera and the thread pulling frames off it is not slowing down.
At the start, my logging shows paint is happening roughly 25-30 times per second.
Over time though, my logging shows it slowing down to the point where after running for roughly a half hour, I'm seeing that my paintEvent is happening only once every 2-3 seconds, creating a noticeable lag.. At the same time, I can tell that mouse-event handling gets very laggy as well. It's as if the whole event loop is getting bogged down. But all my logging (ie. timing various paint and mouse event handling internally) shows that the actual execution time of my various handlers isn't increasing, nor do I see in task manager any evidence of memory leaks. If I turn off all my logging, the behavior is unchanged.
What are some things I might look to to help figure out what is bogging down the event loop?
-
Hmm
Did you check the OS state when it becomes slow?
Its not massive ram usage or fragmentation? -
Yah, nothing seems out of the ordinary as far as task manager, threads, handle count or even CPU utilization, and I can switch to other programs and they all run smooth.
-
Turns out it has nothing to do with Qt, for all intents.. I had a GUI control which could be controlled by the user but would also update itself based on externally generated events (from hardware).. there was a sort of signal/slot recursion going on for an ever increasing number of children objects.. A bit of refactoring and the problem went away.