It is not possible to tell how many times the pid_max
wrap has occured. One work around to not encounter the pid_max
wrapping is to increase the pid_max
value inside,
cat /proc/sys/kernel/pid_max
The above command will let you know the maximum available processes in your system. You can increase the max_pid value as,
echo 4194303 > /proc/sys/kernel/pid_max
or even,
sysctl -w kernel.pid_max=4194303
However, you need to investigate if there are some processes that are currently utilizing the memory.
You can run either ps -A
or ps -e
to see what processes are currently utilizing your system's memory.
Why is it not possible to determine the wrap?
From this answer,
Most systems simply keep a count of the last PID generated, add one
(wrapping at a maximum number such as 65535 or a bit smaller - often
the wrap occurs at 65000 or even 60000), and check that the number is
not currently in use (repeating if the PID is still in use - so PID 1,
the kernel, is still there and doesn't get 'reissued').
Other security minded systems generate a number at random and check
that it is not in use.
At any given time, it is guaranteed that all PID numbers are unique.
So even if pid_max
is reached you still might have some pids that are currently not being used and so the system can still use those pids. As per as I know, the only time when you can know that you are out of pids is when you encounter an error as this comment says,
If you have processes > pid_max, you get error message like "No more
processes...