.Net:我收到以下异常 InteropServices.COMException:“系统中无法创建更多线程。”
我有与某些 COM 对象通信的 .Net 应用程序,并且在 COM 中出现以下异常: System.Runtime.InteropServices.COMException (0x800700A4): 系统中无法创建更多线程。 (HRESULT 异常:0x800700A4)
这是否意味着 COM 对象创建了太多线程(据我所知,线程限制是针对进程的)或者 Windows 中有太多线程(可能是句柄太多)? 或者谁对失败负责,是我的系统,还是 COM 对象?
I have .Net application which communicates with some COM object, and I got the following exception in the COM:
System.Runtime.InteropServices.COMException (0x800700A4): No more threads can be created in the system. (Exception from HRESULT: 0x800700A4)
Does it means that the COM object created too many threads (as far as I know the threads limit is for process) or that there are too many threads in Windows (maybe too many handles)?
Or who's responsible for the failure, my system, or the COM object?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此问题的根本原因是 COM 对象为每个调用创建一个新线程,从而导致资源占用。
本文 (存档版本)解释线程限制问题:
“因为每个线程都消耗进程地址空间的一部分,所以进程对它们可以创建的线程数量有一个基本限制,这是由它们的地址空间大小除以线程堆栈大小决定的。”
The root cause for this issue was that the COM object was creating a new thread for each call, resulting in resource likage.
This article (archived version) explains the threads limit issue:
"Because each thread consumes part of a process’s address space, processes have a basic limit on the number of threads they can create that’s imposed by the size of their address space divided by the thread stack size."