Today, an environment hung up. First, restart it. It was found that it didn’t get up. The following error was reported:
....
Cannot allocate memory
1. Check whether the thread is full first:
# check the maximum allowed processes
[root@test ~] sysctl kernel.pid_max
kernel.pid_max = 32768
#View the number of processes in progress on this server
[root@test ~] ps -eLf | wc -l
1597
2. Compare the above two values. If the two values are similar, increase the number of allowed processes:
Modify PID_ Max value (custom)
[root@test ~] echo 999999 > /proc/sys/kernel/pid_max
Settings take effect permanently
[root@test ~] echo "kernel.pid_max=999999" >> /etc/sysctl.conf
[root@test ~] sysctl -p
3. If it is not, check the Tomcat log:
then modify the memory allocation:
1. [root@test ~] vim/etc/sysctl.conf
vm.overcommit_memory=1
[root@test ~] sysctl -p
2.[root@test ~] echo 1 > /proc/sys/vm/overcommit_memory
[root@test ~] sysctl –p
3. [root@test ~] sysctl vm.overcommit_memory=1
Explanation:
memory allocation strategy in the kernel: overcommit_Memory
optional values: 0, 1, 2
0,: indicates that the kernel will check whether there is enough available memory for the process to use; If there is enough available memory, the memory application is allowed; Otherwise, the memory request fails and the error is returned to the application process
1: indicates that the kernel is allowed to allocate all physical memory regardless of the current memory state
2: indicates that the kernel allows to allocate more memory than the sum of all physical memory and swap space.