PDA

View Full Version : How to peek at the Event queue?



TheRonin
7th May 2009, 09:41
I'm writing a program that uses some third-party libraries. I've noticed that my program's memory and cpu useage increases with time. The CPU goes from 1-2% to 70% overnight and the memory goes from 2% to something like 15%. I've run valgrind and except for the usual whine about Qt not freeing memory i'm not getting any warnings about the code i've written. The third-party libraries i'm using aren't discoverable.

Could the problem be caused by events being placed on the event queue faster than they can be processed? The increasing processing of events would explain the cpu useage and the growing queue would explain the increase in memory. To test my theory i'd like to see the size of the event queue. Is there any way to do this? Calling QCoreApplication::hasPendingEvents() doesn't really tell me what i want to know since i need to see that the queue increases with size over time and in correlation to the increase in cpu and memory useage.

Thanks in advance!

wysota
7th May 2009, 10:25
You can either set an event filter on the application object and monitor the flow of events through your program or you can tap into QAbstractEventDispatcher somehow and do the same.

TheRonin
7th May 2009, 13:42
I've tried installing an eventFilter on the application object and am currently waiting to see some sort of a trend with regard to the number of events per minute. I am a bit concerned however that this won't work simply because i'm still not seeing if the queue is being filled faster than it's being emptied.

Please correct me if i'm wrong but the eventFilter only receives events as they are being dispatched from the queue, right?

wysota
7th May 2009, 14:21
I've tried installing an eventFilter on the application object and am currently waiting to see some sort of a trend with regard to the number of events per minute. I am a bit concerned however that this won't work simply because i'm still not seeing if the queue is being filled faster than it's being emptied.
It doesn't matter. What matters is the potential increase of the number of events in the queue -- all events will be processed eventually. You can craft timer events to have marks telling you how many events have been posted into the queue between two marks as events are processed in sequence (with small exceptions but that shouldn't influence your situation).



Please correct me if i'm wrong but the eventFilter only receives events as they are being dispatched from the queue, right?

Yes, that's correct.