What 'quota' is being referred to in this exception message: Not enough quota is available to process this command

The amount of Windows resources of a specific type that a process could allocate is technically only restricted by the amount of virtual memory available to a process. Which can be a rather large number, especially on the 64-bit version of Windows. Some of these resources are withdrawn from an internal heap from which all other processes withdraw as well. Still a very large number if Windows would let one process consume it all.

Which of course doesn't make sense, a process should never be allowed to gobble up all available resources. Which is what a quota does, it sets an upper limit to the counted number of resources of a certain type. Common examples are 10,000 windows, 10,000 GDI objects, 10,000 handles. Not all of them are nice round numbers like this btw.

It would take knowing more about what your PostMessage() call does, but a reasonable guess is that it is pushing the message queue size past the quota. Again, a resource that's technically only limited to the size of available virtual memory. But practically should stay well south of that. If accurate, you are posting messages faster than they can be consumed, throttling is required. That this happens at the exact time your program is terminating suggests another explanation might be necessary. A thread shutdown order problem, maybe.


According to MSDN:

There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERPostMessageLimit

The minimum acceptable value is 4000.