PHP Warning: require_once(): Unable to allocate memory for pool [Resolved]

Question: For the past two weeks, I started seeing Apache logging PHP warnings as “Unable to allocate memory for pool“. The error is logged for every page refresh and occurs for almost every page in my website. Moreover the error was triggered by various PHP functions such as require_once, include_once, require, include.

Here’s a snippet of the log…

PHP Warning:  require_once(): Unable to allocate memory for pool
PHP Warning:  include_once(): Unable to allocate memory for pool

After searching in Google, I understand that the error is triggered by Alternative PHP Cache (APC) plugin…But I’m not sure which APC attribute should be changed to resolve this issue. Could someone help me?

– Mani


Mani, you are already half way through. Yes, the issue is due to Alternative PHP Cache plugin. But to find the exact memory usage of APC, follow the below steps.

# cp /usr/share/pear/apc.php /var/www/html
# vi /var/www/html/apc.php

Lookout for the below lines:

defaults('ADMIN_USERNAME','apc'); // Admin Username
defaults('ADMIN_PASSWORD','setpassword'); //Admin password

Set APC username and password in the above two lines.

Now access, and you should see APC usage statistics as below:

APC PHP stats

The apc.php stats should tell if you are running out of memory. Lookout for ‘Free‘ and ‘Used‘ fields, Hits and misses of Memory usage graph. If memory usage stats report less ‘Free’ memory, then you shall try increasing the below attribute in php.ini or at php.d/apc.ini

Increase the size of shared memory as below (by default 8M to something higher – 256M or 512M)


Now, you should restart the web server as below:

For apache web server:

/etc/init.d/httpd restart

For NGINX web server:

/etc/init.d/nginx restart

When done, check if the error has vanished from the web server log. If not, increase ‘apc.shm_size‘ again. Between, check if other parameters of APC is causing this issue.

Have a query? Contact us via the footer link and our experts will answer.

Topics :

vps germany

Get Free Email Updates

Disclaimer: The content published in this article is the views of the author only. Techglimpse does not gurantee accuracy, completness or validity. If you believe the content on this post violates your copyright, please send us a mail for removal. Read more.