error “Cannot allocate memory” while executing commands

  • You should increase /proc/sys/kernel/pid_max sysctl. Otherwise, execute the following command to check which app is forking multiple threads.

#ps -eLF

  • Error “Cannot allocate memory” indicates that the system is running out of PID (process ids). In other words, the number of threads/processes present on the system has reached the maximum limit, which is delimited by /proc/sys/kernel/pid_max sysctl.
  • You can check the value of pid_max on the system as follows:

#cat /proc/sys/kernel/pid_max
40000

  • To set the value of pid_max, execute the following command as root.

sysctl -w kernel.pid_max=32768
kernel.pid_max = 32768

  • The value can only be extended up to a theoretical maximum of 32768 for 32 bit systems or 4194304 for 64 bit.

Leave a Reply

Your email address will not be published. Required fields are marked *