views:

733

answers:

2

How many messages does the queue for a standard window hold? What happens when the queue overflows?

The documentation for GetMessage and relatives doesn't say anything about this, and PeekMessage only gives you a yes/no for certain classes of messages, not a message count.

This page says that the queues are implemented using memory-mapped files, and that there is no message count limit, but that page is about WinCE. Does this apply to desktop Win32 as well?

+4  A: 

10000 by default, but it can be adjusted via the registry.

If queue overflows, PostMessage fails.

Documentation here:

http://msdn.microsoft.com/en-us/library/ms644944(VS.85).aspx

Corey Trager
That covers 2000/XP - any idea about Vista?
Ben Straub
I just looked at the registry key listed in that article on a Vista Business SP1 machine, and it's set to 10000. I don't know if that's the only factor in determining the queue length on Vista, though.
Branan
I don't *KNOW* but it would be unlikely to be different. Vista isn't that revolutionary, I don't think...
Corey Trager
One more thing though - if you are thinking of using the message queue as, um, a queue that's being fed by another thread, I think you'll disappointed by the results. You'll end up with a unresponsive GUI. Our company has a lot of experience with exactly this failed designed technique.
Corey Trager
+2  A: 

As stated in the MSDN article, if you need to worry about the size of the message queue, you might be better off redesigning your application.

Heng-Cheong Leong
In this case, we're on the other side of the queue; our device driver is posting the messages, and a toy Flash application was bogging down after a few minutes.
Ben Straub