Saturday 16 February 2013

Fork : Cannot allocate memory

Recently I experienced an issue when I tried restarting cpanel service 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.


You can see the value as below


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

Another method to increase the limit by running the command in the main node.

vzctl set <ve_node> --privvmpages 100000:100000 --save

1 comment:

  1. I always find it enjoyable reading your posts you have on your site. Will be returning often'keep it up!
    best usa windows vps


Note: only a member of this blog may post a comment.