What is the maximum process id I can get by calling DWORD GetProcessId(HANDLE)
or DWORD GetCurrentProcessId()
? It is not documented on the API's documentation page.
On 32-bit platforms, 32768 is the maximum value for pid_max.
On Solaris, the maximum value of a process ID is a kernel tunable parameter — pidmax in /etc/system — that defaults to 30,000 and that can be set anywhere between 266 and 999,999.
On a 32-bit system, the maximum PID is 32767. Each time the limit is reached, the kernel resets its process ID counter so that process IDs are assigned starting from low integer values. And it will be reset to 300, rather than 1.
All PIDs are nine digit numbers that begin with a 7.
According to the Pushing the Limits of Windows: Processes and Threads blog post by Mark Russinovich number of processes is limited only by available memory. So theoretically maximum process id is DWORD_MAX aligned to 4: 0xFFFFFFFC (as pid/tid values are aligned to 4 on Windows).
I couldn't find an official statement on it but since it's stored and returned as a DWORD you should assume it can use the entire 32-bit range. In practical systems I've never seen a PID large than ~200,000 though - since Windows will reuse PIDs they rarely get larger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With