When I tried to log in to the CVM via VNC, the error message “Cannot allocate memory” appeared.
There are too many huge pages. The default huge page size is 2048 KB. The number of huge pages is stated in
/etc/sysctl.conf. If there are 1280 huge pages (as shown below), 2.5 GB of memory are taken. In case of low instance specification, there may not be enough memory for proper system running, and you cannot enter the system after restarting it.
- Perform the troubleshooting procedure to check whether the total number of processes exceeds the limit.
- Modify the configurations of huge pages as needed.
- Check whether the total number of processes exceeds the limit as instructed in Log Error “fork: Cannot allocate memory”. If not, proceed to the next step.
- Enter the single user mode and log in to the CVM. For detailed directions, see Booting into Linux Single User Mode.
- Run the following command to check the configurations of huge pages.
If there are many huge pages, perform the following steps to modify the configurations.
cat /etc/sysctl.conf | grep hugepages
- Run the following command to open the
/etc/sysctl.conf configuration file with VIM editor.
- Press i to enter the edit mode and reduce the value of
vm.nr_hugepages as needed.
- Press Esc, enter :wq, and press Enter to save the configurations and exit the VIM editor.
- Run the following command for the configuration to take effect immediately.
- Then restart the CVM, and you can log in normally.