Print Page | Close Window

TabClientWnd using lots of CPU

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=6090
Printed Date: 14 July 2025 at 3:19am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: TabClientWnd using lots of CPU
Posted By: danpetitt
Subject: TabClientWnd using lots of CPU
Date Posted: 11 January 2007 at 4:56pm
I got a few complaints from some users of my software saying that on their Dual XEON dev machines, my product was using 15-20% of the CPU in total (across 4 processors) when they werent doing anything at all.

This figure went down slightly if they had only 1 doc open but went up significantly with lots of documents.

After some testing, we found that if they turned off the client tabs option so they just had maximised child windows for each document it went down to 0%.

It seems that the MDITabClientWnd is using a lot of CPU, have you noticed anything in this area and/or done any profiling on it?



Replies:
Posted By: danpetitt
Date Posted: 11 January 2007 at 5:43pm
It looks like CXTPTabClientWnd::OnIdleUpdateCmdUI is calling UpdateContents which is quite a heavy function.


Posted By: Oleg
Date Posted: 12 January 2007 at 12:47am
Hi,
 
in issue https://forum.codejock.com/forum_posts.asp?TID=6027 - https://forum.codejock.com/forum_posts.asp?TID=6027  you wrote that you added pFoundItem->SetImageIndex( pFoundItem->GetImageIndex() );
It will Recalculate layout each time OnIdleUpdateCmdUI called.
remove it.
 
 
Set breakpoint in CalcWindowRect and be sure it called if client size changed and not all time.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: danpetitt
Date Posted: 12 January 2007 at 2:41am
Thank you, I hadnt got around to reversing my change on your code. So glad it was something simple ... thanks!

Wot great support, this could have been a nightmare to resolve if you hadnt remembered about my other change.

Well done Oleg!


Posted By: Simon HB9DRV
Date Posted: 12 January 2007 at 3:32am
Another thing to consider is CWinApp::IsIdleMessage - if you override this you can greatly reduce idle processing.


-------------
Simon HB9DRV


Posted By: mgampi
Date Posted: 12 January 2007 at 1:26pm
Hi Simon;
 
I agree by 100%. In my case I had a MDI application with online trending document types. These documents used timers (WM_TIMER messages) posted by the individual MDI child frame windows to update their contents. These WM_TIMER messages increased the CPU usage due to excessive calls of OnIdleUpdate... .
After overriding the IsIdleMessage the CPU usage went down to 0% from up to 100% when more than 10 to 15 documents were open!
 


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: danpetitt
Date Posted: 12 January 2007 at 5:56pm
What is this override used for then and what did you do, just return FALSE?


Posted By: mgampi
Date Posted: 13 January 2007 at 7:21am
Hi Dan;
 
This virtual function determines whether a message in the message queue is a message good for idle processing or not. If this function returns TRUE, the OnIdleUpdate... processing is done (OnUpdateCommandUI() handlers are called).
In the default implementation WM_TIMER messages are defined as 'idle' messages, resulting in OnUpdateCommandUI() calls.
In my application, each mdi child window has started its own timer and the timer interval is about 200ms. This means that after opening one window, the OnUpdateCommandUI() handlers are called 5 times per second. 10 open child frame windows lead to 50 calls to all OnUpdateCommandUI(). This uses lots of CPU!!!
 
So I wrote my own IsIdleMessage() to return also FALSE when WM_TIMER messages are handled.
 


-------------
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022


Posted By: Simon HB9DRV
Date Posted: 14 January 2007 at 3:53am
Originally posted by mgampi mgampi wrote:

Hi Dan;
 
This virtual function determines whether a message in the message queue is a message good for idle processing or not. If this function returns TRUE, the OnIdleUpdate... processing is done (OnUpdateCommandUI() handlers are called).
In the default implementation WM_TIMER messages are defined as 'idle' messages, resulting in OnUpdateCommandUI() calls.
In my application, each mdi child window has started its own timer and the timer interval is about 200ms. This means that after opening one window, the OnUpdateCommandUI() handlers are called 5 times per second. 10 open child frame windows lead to 50 calls to all OnUpdateCommandUI(). This uses lots of CPU!!!
 
So I wrote my own IsIdleMessage() to return also FALSE when WM_TIMER messages are handled.
 

I had to ignore most of my registered messages. I have quite a few common controls in the toolbars and updating these is / was quite expensive.


-------------
Simon HB9DRV



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net