Windows 7 limit the number of threads that a process creates?

2

Do some versions of Windows 7 (32 or 64 bits) manage the number of threads that any specific process are creating? If so, is there a way to configure a maximum limit of threads on system (in the registry for example)?

Diogo

Posted 2011-06-21T18:39:33.143

Reputation: 28 202

Is this a question for your own program? Or do you want to limit other programs on your system? – EBGreen – 2011-06-21T20:23:27.127

I want to limit the thread number that my windows handle. – Diogo – 2011-06-21T20:27:16.003

Nothing you can do about it then if you didn't write the program that is creating threads. – EBGreen – 2011-06-21T20:28:58.200

And just to be clear, even if there were a way to limit it, you would most likely just break the program that is trying to make a new thread. If the program was properly coded it would handle the failure to create the thread, but at best it means that the program would not be able to do whatever it was creating the tread to do. – EBGreen – 2011-06-21T20:31:14.500

Answers

3

The OS does not explicitly limit the creation of threads. It is essentially controlled by resource constraints. If the OS has the resources the the process can create as many threads as it wants until there are no more resources.

EBGreen

Posted 2011-06-21T18:39:33.143

Reputation: 7 834

In a 32-bit app running without the "large address aware" option, assuming the app has not overridden the default stack allocation, there is a derived limit of somewhat less than 2000 threads per process. This is because the default reserved stack size is 1 MiB, and the process user mode address space is 2 GiB. "Somewhat less" is because there is already some stuff in the address space just to support any simple program (so you don't have quite 2 GiB free in a new process, and what you do have isn't all in one contiguous chunk). – Jamie Hanrahan – 2015-10-24T18:29:33.703

1

Yes, you (sort of) can. With multi-processor cpu's, you can set the number of cores used by a program. For instance, an I8 cpu with 8 cores, you can limit your computer to use a max of only 7 cores (or 6,5,4..). Run task manager (ctrl-alt-del), goto Processes and select the program. Right click on the program name and select 'set affinity'. A window will open up showing available cores for the program and here you can remove, or add later, cores for your program to use.

Georg

Posted 2011-06-21T18:39:33.143

Reputation: 11

1I don't believe there is an i8 CPU. Intel only has i3, i5, and i7 CPUs. Please clarify. – music2myear – 2018-02-01T17:22:33.083

1

The technical concept to achieve this is a Job which allows for Limits.

There's pretty much that can be limited, but not the threads (at the time answering the question).

Thomas Weller

Posted 2011-06-21T18:39:33.143

Reputation: 4 102