Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - TabClientWnd using lots of CPU
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

TabClientWnd using lots of CPU

 Post Reply Post Reply
Author
Message
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Topic: TabClientWnd using lots of CPU
    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?
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 11 January 2007 at 5:43pm
It looks like CXTPTabClientWnd::OnIdleUpdateCmdUI is calling UpdateContents which is quite a heavy function.
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2007 at 12:47am
Hi,
 
in issue 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
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post 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!
Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
danpetitt View Drop Down
Senior Member
Senior Member


Joined: 17 July 2005
Location: United Kingdom
Status: Offline
Points: 109
Post Options Post Options   Thanks (0) Thanks(0)   Quote danpetitt Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2007 at 5:56pm
What is this override used for then and what did you do, just return FALSE?
Back to Top
mgampi View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14 July 2003
Status: Offline
Points: 1198
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017
Back to Top
Simon HB9DRV View Drop Down
Senior Member
Senior Member
Avatar

Joined: 07 July 2005
Location: Switzerland
Status: Offline
Points: 458
Post Options Post Options   Thanks (0) Thanks(0)   Quote Simon HB9DRV Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.