Maximum number of processes in linux [closed]

What is the maximum limit to the number of processes possible in a linux system? How can we find it ?


Your kernel should export this information in procfs:

cat /proc/sys/kernel/pid_max

This is the maximum number of unique process identifiers your system can support.

Since it is a file, /proc/sys/kernel/pid_max can be inspected from any capable programming language.


sysctl kernel.pid_max

or

cat /proc/sys/kernel/pid_max

As suggested by Ninefingers.

For completeness, you can change it temporarily by writing to /proc/syskernel/pid_max or permanently by adding:

kernel.pid_max = 4194303

to /etc/sysctl.conf. 4194303 is the maximum limit for x86_64 and 32767 for x86.


Short answer to your question : Number of process possible in the linux system is UNLIMITED.

But there is a limit on number of process per user(except root who has no limit).

And you can check your user limits with below command (apposite to "max user processes").

$ ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256447
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 128000
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 500000
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

If you want to increase the limit on number of process for a particular user(for eg: hadoop ) , you need to make below entry in /etc/security/limits.conf

hadoop - nproc 500000

kernel.pid_max is a limiting factor, but at least as important is kernel.threads-max. It's worth noting that the default nproc ulimit for each user is kernel.threads-max divided by two, and that every thread counts toward a user's nproc limit. Thus, ps -u $USER may make it appear that a user has not exhausted their nproc limit, but ps -L -u $USER could tell a very different story.