Pages

Tuesday 16 April 2013

Fork : Cannot allocate memory(VPS Server)

In a VPS server, this usually occurs when VPS is running out of resources especially RAM. By restarting the VPS you can fix the issue. But it would be a temporary fix and it will only allow you to login to the server, but cannot execute some of the commands.
Check for the failcnt value of privvmpages and kmemsize variables. Due to the increase in failcnt, you are receiving the error “fork:Cannot allocate memory”.  Please check /proc/user_beancounters on vps for checking the failcount.

$ cat /proc/user_beancounters
uid      resource         held        maxheld    barrier    limit    failcnt
privvmpages               33656     44989       96550       96550    106507

You can increase the limit by editing the following file in the main node.

$ /etc/sysconfig/vz-scripts/<ve-node>.conf

You can see the value as below
PRIVVMPAGES=”96550:96550″

Increase the value as you need and then restart the vps.
Another method to increase the limit is using command as follows:

$ vzctl set <ve_node> –privvmpages 12752512:12752512 –save

You will now be able to restart cpanel and it will be working fine.