windows 此异常消息中引用的“配额”是什么:没有足够的配额可用于处理此命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5032258/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What 'quota' is being referred to in this exception message: Not enough quota is available to process this command
提问by sackoverflow
I have a .NET application that throws the following exception:
我有一个抛出以下异常的 .NET 应用程序:
System.ComponentModel.Win32Exception : Not enough quota is available to process this command
at MS.Win32.UnsafeNativeMethods.PostMessage(HandleRef hwnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at MS.Win32.ManagedWndProcTracker.HookUpDefWindowProc(IntPtr hwnd)
at MS.Win32.ManagedWndProcTracker.OnAppDomainProcessExit()
at MS.Win32.ManagedWndProcTracker.ManagedWndProcTrackerShutDownListener.OnShutDown(Object target)
at MS.Internal.ShutDownListener.HandleShutDown(Object sender, EventArgs e)
I can't reproduce this exception personally, but I get lots of exception reports from users.
我个人无法重现这个异常,但是我从用户那里得到了很多异常报告。
What is the 'quota' being referred to? The stack trace leads me to believe that it might be a problem with the Windows message queue.
所指的“配额”是什么?堆栈跟踪使我相信这可能是 Windows 消息队列的问题。
Any ideas about what might cause this error, or how to fix it would be greatly appreciated.
关于可能导致此错误的原因或如何修复它的任何想法将不胜感激。
EDIT, further info:This is on 32 bit Windows XP on all machines, and the exception is not in mycode as such, but a .NET Framework event handler of some sort. The application itself does not make any PostMessage calls.
编辑,更多信息:这是在所有机器上的 32 位 Windows XP 上,异常不在我的代码中,而是某种 .NET Framework 事件处理程序。应用程序本身不进行任何 PostMessage 调用。
采纳答案by Hans Passant
The amount of Windows resources of a specific type that a process couldallocate 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 oneprocess consume it all.
进程可以分配的特定类型的 Windows 资源量在技术上仅受进程可用虚拟内存量的限制。这可能是一个相当大的数字,尤其是在 64 位版本的 Windows 上。其中一些资源是从内部堆中撤回的,所有其他进程也从该堆中撤回。如果 Windows 允许一个进程全部使用它,仍然是一个非常大的数字。
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.
这当然没有意义,永远不应该允许进程吞噬所有可用资源。这就是配额的作用,它为某种类型的资源计数设置了上限。常见的例子是 10,000 个窗口、10,000 个 GDI 对象、10,000 个句柄。顺便说一句,并非所有这些都是很好的整数。
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 exacttime your program is terminating suggests another explanation might be necessary. A thread shutdown order problem, maybe.
需要更多地了解 PostMessage() 调用的作用,但合理的猜测是它正在推动消息队列大小超过配额。同样,这种资源在技术上仅限于可用虚拟内存的大小。但实际上应该保持在南边。如果准确,您发布消息的速度比消耗它们的速度快,则需要进行节流。这发生在您的程序终止的确切时间表明可能需要另一种解释。可能是线程关闭顺序问题。
回答by servermanfail
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
每个消息队列有 10,000 条已发布消息的限制。这个限制应该足够大。如果您的应用程序超出限制,则应重新设计以避免消耗如此多的系统资源。要调整此限制,请修改以下注册表项。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows\USERPostMessageLimit
The minimum acceptable value is 4000.
可接受的最小值为 4000。
回答by servermanfail
It could be NTFS Quotas. For more information, see http://technet.microsoft.com/en-us/library/cc786220(WS.10).aspx
它可能是 NTFS 配额。有关详细信息,请参阅http://technet.microsoft.com/en-us/library/cc786220(WS.10).aspx
回答by Chris Haas
My solution was to go to Control Panel>Offline Files and increase the amount of disk space available to both offline files in general and the temporary space (for the sake of simplicity, I increased it by the same amount of the number of files I needed to move but less would probably have done).
我的解决方案是转到控制面板>脱机文件并增加可用于一般脱机文件和临时空间的磁盘空间量(为简单起见,我增加了与我需要的文件数量相同的数量移动,但可能会做得更少)。