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/<ve-node>.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 <ve_node> –privvmpages 100000:100000 –save

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

Advertisements
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: