CentOS execution command error: – bash: fork: cannot allocate memory processing / viewing process number

Contents of articles

Error reported by CentOS when executing command: – bash: fork: cannot allocate memory

Error reported by CentOS when executing command: – bash: fork: cannot allocate memory

Background:
executing any command will report – bash: fork: cannot allocate memory, but there is still a lot of free memory.

Problem analysis:
the reason is that the number of processes is full, which exceeds the default value set by the system

View the maximum number of processes

sysctl kernel.pid_max

View the number of processes

ps -eLf | wc -l

You will find that the number of all processes is almost more than the default number of processes

After modifying the maximum number of processes, the system can recover without restarting the process.

echo 1000000 > /proc/sys/kernel/pid_max

Permanent effect

echo "kernel.pid_max=1000000 " >> /etc/sysctl.conf
sysctl -p


Read More: