Friday, March 1, 2013

Fork : Cannot allocate memory

Recently I experienced an issue when I tried restarting cpanel in the server. On executing the cpanel restart command, it showed the error "fork : Cannot allocate memory".

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.

The issue occurs since the server has exceeded the limit set for privvmpages and kmemsize. You can view the values set for these variables in the file /proc/user_beancounters.

cat /proc/user_beancounters

Check for the failcnt value for these two variables. Due to the increase in failcnt, you are receiving the error "fork:Cannot allocate memory". In my case the privvmpages value was having failcnt value.

uid resource held maxheld barrier limit failcnt
privvmpages 33656 44989 98304 98304 106507
You can increase the limit by editing the following file in the main node.

/etc/sysconfig/vz-scripts/.conf

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

Increase the value as you need and then restart the vps.

Another method to increase the limit is using command as follows:
vzctl set –privvmpages 100000:100000 –save

That's it !!! You will now be able to restart cpanel and it will be working fine.

No comments:

Post a Comment