Thursday November 26th

Wednesday November 25th

3 Kicks

Max Number of Threads Per Windows Process

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


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.

Commenting on Stories is limited for now and will open up to those recommended by the community. Learn how
Loading DotNetKicks...
brought to you by the Kicks Network