Sure, I can get spurious WM_MOUSEMOVE messages, but why do they keep streaming in?

Raymond Chen

I wrote some time ago that the window manager generates spurious WM_MOUSEMOVE messages in order to let programs know that the mouse has entered the window even if the reason was a window hierarchy reshuffle rather than a physical motion of the pointing device. But some people have noticed that that explanation fails to account for all the WM_MOUSEMOVE messages that are being delivered. In particular, the reasoning fails to explain why a stream of WM_MOUSEMOVE messages is being generated. So where is this infinite stream of WM_MOUSEMOVE messages coming from, even when the window hierarchy is stable?

They’re most likely coming from some third party so-called enhancement software.

The Windows performance and mobility teams keep a close eye on these sort of continuous phenomena. The performance folks are interested because this continuous stream of messages suck away resources that could be used for something more productive. It’s not just the cost in CPU. The memory in the message handling code path can’t be paged out since it’s being hit all the time. The context switches force CPU caches to be flushed. Algorithms which had been tuned to reside entirely within the L2 cache now find themselves going out to slower main memory. Meanwhile, the mobility team is concerned because all this continuous activity runs down your battery, prevents the CPU from going into a low-power state, and prevents your screen saver from kicking in.

If you find a continuous stream of WM_MOUSEMOVE messages, then there is some continuous activity going on that is causing it. It might be some software that is polling the mouse in order to provide “extra value”. For example, they might check the mouse cursor position and try to guess what it is positioned over, but they never realize that “You know, if nothing has changed, the answer is probably the same as it as last time you checked.” Or, as the author of linked posting above eventually figured out, it might be a buggy wireless mouse which not only is sucking down your CPU and preventing your screen saver from running, but is also draining your wireless mouse battery!


Discussion is closed.

Feedback usabilla icon