Unable to allocate memory for pool, How to fix it

I am hosting a number of websites on my Debian server running on NginX, all of my website's log files shows me an error like this

2011/11/23 10:01:03 [error] 5320#0: *349 FastCGI sent in stderr: "PHP Warning: Unknown: Unable to allocate memory for pool. in Unknown on line 0" while reading response header from upstream

I am using APC 3.1.6 with the latest version on PHP and Nginx


Solution 1:

I had the same issue:

  • I reconfigured php-fpm (see my php-fpm.conf) to recycle processes more often and also how to react when processes don't respond anymore or throw errors
  • I configured APC (see my apc.ini) to use apc.mmap_file_mask=/dev/zero

Then the error disappeared.

Solution 2:

Change you apc.ini settings like below

apc.mmap_file_mask=/dev/zero
apc.shm_size=64M
apc.ttl=0

it works

Refer apc.configuration.php