Max Number of Threads Per Windows Process

added by eknowledger
5/1/2012 9:12:08 AM

3 Kicks, 632 Views

Developers usually thinks that Windows has a default value for the max number of threads a process can hold. while in fact the limitation is due to the amount of address space each thread can have. When you create new thread, it has some memory in the kernel mode, some memory in the user mode, plus its stack, the limiting factor is usually the stack size. The secret behind that is the default stack size is 1MB and the user-mode address space assigned to the windows process under 32 bit Windows OS is about 2 GB. that allow around 2000 thread per process (2000 * 1MB = 2GB).


5/1/2012 9:11:17 AM
I think this is an argument for using an event-driven approach rather than multithreaded. It doesn't seem like there would be any advantage to consuming that amount of memory just to have that many separate threads running, especially if the threads are going to spend most of their time sleeping.