Question

Excessive CPU usage when moving the mouse

Asked by: zebada

Using D7 on WinXP Pro on a P3 800MHz machine.
My Delphi app is showing 80% to 100% CPU usage (as displayed in task manager) simply by moving the mouse pointer over my application's main form. The Delphi App is not executing any user code.

In an attempt to discover the reason for the high CPU usage, I have added WndProc() to my app and I display the messages that I am receiving form Windows.
I get 1000's of messages per mouse move (just 1 pixel move of the mouse pointer).

I am not sure if these messages are a reuslt of me displaying the messages or if they are the messages that are responsible for the high CPU usage.
The messages that I am "Seeing" 1000's of times per mouse move are:
45108 (CM_INVALIDATE) and 45119 (CM_ACTIONUPDATE)

How can I figure out why/how and by what these messages are being generated and how can I figure out how to stop them?

Regards
Paul

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-12-14 at 06:27:49ID21241785
Tags

delphi

,

cm_invalidate

,

cpu

Topic

Delphi Programming

Participating Experts
2
Points
500
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. WndProc problem
    I try to make a component who create my own caption for FORM derived from TComponent . How can I hook and override WndProc for my form? this is my constructor constructor Ttest.Create(AOwner:TComponent); begin inherited Create(AOwner); FOwnerForm:=TForm(AOwner); FHOw...
  2. d7 big big problem
    When I try to run d7 I get this message: Borland license information was found, but it is not valid for delphi. you cannot run delphi without this information any ideas??? thanks :)
  3. How to use FTP service in D7
    Dear advisor ! i use d7 i already read at http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20614893.html But i could not find NMFTP Control at Component Penal in D7. How could i add it. Or is there some new way in D7 Thank for all consider Beg...
  4. D7 compared to D8
    Hi, I have just started to explore the latest Delphi, and started to think if there is something I might lose by changing to it. In other words, does D7 have anything, which is really missing from D8, is there any reason for sticking to D7? I'm especially eager to hear the ...
  5. Windows Messages (WndProc)
    if i override the WndProc procedure i can do things like if Msg.Msg=wm_whatever blah blah blah.... It works fine but it only gives the messages for that form, does this mean i have to create a new component and inherit the old component and add a wndproc to it? or is there ...
  6. recompileing ADODB in D7
    PROBLEM: I am using a tAdoQuery to connect to a FOX db. All the integer(decimals in fox) results are returned as pozitive values even if they are negative(ex: -1 becomes 1). I have looked on google for "negative numbers tadoquery" and I have come across a quality ce...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: Workshop_AlexPosted on 2004-12-14 at 06:44:17ID: 12819655

Seems to me that there's some system hook hooked into your mouse messages, executing some code even while you think nothing is executed... nd yes, the mouse will send 1000s of messages when you move it. nd normally, those movements will be processed extremely fast. ut in you case, something is slowing things down a bit.

In this case I think it is related to an actionlist in your application. Possibly an action is linked to the form or other control and every time you move over the form, it checks if the action is enabled or not. I think one of your actions OnUpdate events is slowing your system down this much... This could even be the update event of one of your standard actions...

 

by: zebadaPosted on 2004-12-14 at 15:20:41ID: 12825381

Thanks Alex, that throws some light on the subject, but I still can't figure out why it is happening.
I do have a TActionManager with about 180 actions in it. None of the actions have any Update events. They only have execute events.

Here's a snip from the messages that I captured from the WndProc procedure:
The 32 occurs each time I move the mouse 1 pixel. I need to figure out why the 45119 messages are occuring (and I need to stop them).

The messages only occur while the mouse is over the main form. If a modal form is open and the mouse is moved over the modal form, then the messages stop. If the open form is non-modal and the mouse is moved over the non-modal form, then the messages continue as if the mouse was over the main form.

Msg: 2952: 45119,0,14555412
Msg: 2953: 45119,0,14547636
Msg: 2954: 45119,0,14552604
Msg: 2955: 45119,0,14582976
Msg: 2956: 32,198560,33554433
Msg: 2957: 45119,0,14534308
Msg: 2958: 45119,0,14535560
Msg: 2959: 45119,0,14538268
Msg: 2960: 45119,0,14539220
Msg: 2961: 45119,0,14539684
Msg: 2962: 45119,0,14540320
Msg: 2963: 45119,0,14540988
Msg: 2964: 45119,0,14542952
Msg: 2965: 45119,0,14543604
Msg: 2966: 45119,0,14544264
Msg: 2967: 45119,0,14446548
Msg: 2968: 45119,0,14545224
Msg: 2969: 45119,0,14446220
Msg: 2970: 45119,0,14569908
Msg: 2971: 45119,0,14572080
Msg: 2972: 45119,0,14583424
Msg: 2973: 45119,0,14583836
Msg: 2974: 45119,0,14574040
Msg: 2975: 45119,0,14574684
Msg: 2976: 45119,0,14575300
Msg: 2977: 45119,0,14575928
Msg: 2978: 45119,0,14576556
Msg: 2979: 45119,0,14577204
Msg: 2980: 45119,0,14447040
Msg: 2981: 45119,0,14446876
Msg: 2982: 45119,0,14549984
Msg: 2983: 45119,0,14550620
Msg: 2984: 45119,0,14551248
Msg: 2985: 45119,0,14551948
Msg: 2986: 45119,0,14547472
Msg: 2987: 45119,0,14388248
Msg: 2988: 45119,0,14547944
Msg: 2989: 45119,0,14548108
Msg: 2990: 45119,0,14548364
Msg: 2991: 45119,0,14548740
Msg: 2992: 45119,0,14549352
Msg: 2993: 45119,0,14580580
Msg: 2994: 45119,0,14580980
Msg: 2995: 45119,0,14581356
Msg: 2996: 45119,0,14529636
Msg: 2997: 45119,0,14529872
Msg: 2998: 45119,0,14530668
Msg: 2999: 45119,0,14552932
Msg: 3000: 45119,0,14577688
Msg: 3001: 45119,0,14577852
Msg: 3002: 45119,0,14578016
Msg: 3003: 45119,0,14578180
Msg: 3004: 45119,0,14575092
Msg: 3005: 45119,0,14557924
Msg: 3006: 45119,0,14558556
Msg: 3007: 45119,0,14559348
Msg: 3008: 45119,0,14560004
Msg: 3009: 45119,0,14560504
Msg: 3010: 45119,0,14561256
Msg: 3011: 45119,0,14558968
Msg: 3012: 45119,0,14549144
Msg: 3013: 45119,0,14549776
Msg: 3014: 45119,0,14554132
Msg: 3015: 45119,0,14554768
Msg: 3016: 45119,0,14556668
Msg: 3017: 45119,0,14555412
Msg: 3018: 45119,0,14547636
Msg: 3019: 45119,0,14552604
Msg: 3020: 45119,0,14582976
Msg: 3021: 32,198560,33554433
Msg: 3022: 45119,0,14534308
Msg: 3023: 45119,0,14535560
Msg: 3024: 45119,0,14538268
Msg: 3025: 45119,0,14539220
Msg: 3026: 45119,0,14539684
Msg: 3027: 45119,0,14540320
Msg: 3028: 45119,0,14540988
Msg: 3029: 45119,0,14542952
Msg: 3030: 45119,0,14543604
Msg: 3031: 45119,0,14544264
Msg: 3032: 45119,0,14446548
Msg: 3033: 45119,0,14545224
Msg: 3034: 45119,0,14446220
Msg: 3035: 45119,0,14569908
Msg: 3036: 45119,0,14572080
Msg: 3037: 45119,0,14583424
Msg: 3038: 45119,0,14583836
Msg: 3039: 45119,0,14574040
Msg: 3040: 45119,0,14574684
Msg: 3041: 45119,0,14575300
Msg: 3042: 45119,0,14575928
Msg: 3043: 45119,0,14576556
Msg: 3044: 45119,0,14577204
Msg: 3045: 45119,0,14447040
Msg: 3046: 45119,0,14446876
Msg: 3047: 45119,0,14549984
Msg: 3048: 45119,0,14550620
Msg: 3049: 45119,0,14551248
Msg: 3050: 45119,0,14551948
Msg: 3051: 45119,0,14547472
Msg: 3052: 45119,0,14388248
Msg: 3053: 45119,0,14547944
Msg: 3054: 45119,0,14548108
Msg: 3055: 45119,0,14548364
Msg: 3056: 45119,0,14548740
Msg: 3057: 45119,0,14549352
Msg: 3058: 45119,0,14580580
Msg: 3059: 45119,0,14580980
Msg: 3060: 45119,0,14581356
Msg: 3061: 45119,0,14529636
Msg: 3062: 45119,0,14529872
Msg: 3063: 45119,0,14530668
Msg: 3064: 45119,0,14552932
Msg: 3065: 45119,0,14577688
Msg: 3066: 45119,0,14577852
Msg: 3067: 45119,0,14578016
Msg: 3068: 45119,0,14578180
Msg: 3069: 45119,0,14575092
Msg: 3070: 45119,0,14557924
Msg: 3071: 45119,0,14558556
Msg: 3072: 45119,0,14559348
Msg: 3073: 45119,0,14560004
Msg: 3074: 45119,0,14560504
Msg: 3075: 45119,0,14561256
Msg: 3076: 45119,0,14558968
Msg: 3077: 45119,0,14549144
Msg: 3078: 45119,0,14549776
Msg: 3079: 45119,0,14554132
Msg: 3080: 45119,0,14554768
Msg: 3081: 45119,0,14556668
Msg: 3082: 45119,0,14555412
Msg: 3083: 45119,0,14547636
Msg: 3084: 45119,0,14552604
Msg: 3085: 45119,0,14582976
Msg: 3086: 32,198560,33554433
Msg: 3087: 45119,0,14534308
Msg: 3088: 45119,0,14535560
Msg: 3089: 45119,0,14538268
Msg: 3090: 45119,0,14539220
Msg: 3091: 45119,0,14539684

 

by: zebadaPosted on 2004-12-14 at 15:57:02ID: 12825637

Ok, I just added a TApplicationEvents control to my main form and put
Handled := true;
in the OnActionUpdate event.
That got the CPU usage back down to 1% - 6% (from 80%-100%) when moving the mouse over the main form.
Can anyone explain why that would work and what side effects that may have on the rest of my application?
Obviously I would prefer to "solve" the problem rather than mask it by doing what I did.

 

by: AqueathPosted on 2004-12-14 at 17:53:14ID: 12826139

Are you using the OnMouseMove event on your main form for anything? If you are calling some code every time the mouse moves this might be the reason for what you are experiencing.

Best regards,
A.

 

by: zebadaPosted on 2004-12-15 at 02:27:34ID: 12828238

No, that's the first thing I checked.
No other visible control on the main form uses onmousemove either.
A few controls on a tab page that is not active use the onmousemove, but I hardly expect those to fire when the controls are not visible.

Paul

 

by: Workshop_AlexPosted on 2004-12-15 at 03:14:52ID: 12828539

It seems to me the problem could be related to some standard action. First of all, do you have an action assigned to your form? (Is a value assigned to Form1.Action?)

And 180 actions is a bit much, although it should not be that bad either. Personally, I try to stay away from the actionlist as much as possible just because it likes to check for updates so often. Then again, if you have no update events, it should process them all pretty fast.

From the helpfiles: TApplicationEvents.OnActionUpdate occurs when an action’s Update method is called and its action list has not already handled it.
This actually says that it gets called when actions don't update themselves. If you happen to have 180 standard actions with no update event, I do think it's a good idea to say here that they are handled. (Setting Handled to true.) If I read the helpfile correctly, the application just starts searching for an update for the action until it finds one or runs out of places to search.

The order in which actions are updated is:
1) The ActionList
2) The Application event
3) The Action
4) The Control linked to the action
5) The active form

Now, it could be that your application is updating all 180 actions on every mouse move. (Technically required because a move of a mouse could already affect one or more actions.) Thus your application goes to the actionlist, the application, the action, a control and finally the active form to see if any update is needed before discovering that no updates are required...
This is why I dislike actionlists so much... While it sure helps keeping your buttons up-to-date, it does slow things down considerably. Then again, in a GUI application the delays caused by this shouldn't be that bad.

I think it might be better to create on TAction.OnUpdate event and let all actions point to this single event, unless you need specific updates for them. (Very useful if you also use standard actions that don't have an OnUpdate event, like the data-aware actions.)
Or possibly reduce the number of actions in your application. Maybe divide your actions over multiple actionlists.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...