.Net: I got the following exception InteropServices.COMException: "No more threads can be created in the system."

3

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?

.net
com

1 Answer

4

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."

answered on Stack Overflow Sep 15, 2011 by Amittai Shapira • edited Mar 24, 2020 by founderio

User contributions licensed under CC BY-SA 3.0