I‘m running PHP version 5.3.3 on CentOS / RHEL 6.x with APC php-pecl-apc-3.1.9. However, I’m getting the following warnings in my php server log file:
[01-Jul-2012 10:50:49] PHP Warning: require_once(): Unable to allocate memory for pool. in /var/www/html/includes/admin.php on line 57
[18-Jul-2012 17:00:08] PHP Warning: include_once(): Unable to allocate memory for pool. in //var/www/html/includes/xmlrpc.php on line 55
[18-Jul-2012 17:00:40] PHP Warning: require(): Unable to allocate memory for pool. in /var/www/html/includes/geshi.php on line 2307

How do I fix these php warnings?

This error is usually related to Alternative PHP Cache (APC). APC is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.


Edit the file /etc/php.d/apc.ini (Debian and/or Ubuntu Linux user edit the /etc/php5/conf.d/apc.ini), enter:
# vi /etc/php.d/apc.ini
Make sure the mktemp-style file_mask to pass to the mmap module is correct and valid one:


Next make sure the size of each shared memory segment, with M/G suffix is set correct as per your requirements. In my case it was set to 8M:

; increased to 96M

You need to adjust the number of seconds a cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry:


The number of seconds a user cache entry is allowed to idle in a slot in case this cache entry slot is needed by another entry:


The number of seconds that a cache entry may remain on the garbage-collection list.


Save and close the file. Make sure you adjust the values as per your web-app requirements. Restart the Apache 2 web server:
# service httpd restart
If you are using the Lighttpd instead of Apache2 web-server, restart the Lighttpd web server:
# service lighttpd restart
If you are using Nginx instead of Apache2 or Lighttpd, restart the Nginx web server:
# service nginx restart
# /usr/local/nginx/sbin/nginx -s reload

Tip: Find out your APC memory usage and hit ratio

You need to find out exact memory usage and hit ratio so that you can set apc.ttl and apc.shm_size as per your work load. Copy /usr/share/php-pecl-apc/apc.php to your /var/www/html directory i.e. Apache DocumentRoot:
# cp /usr/share/php-pecl-apc/apc.php /var/www/html
Edit /var/www/html/apc.php and set the admin password :


Save and close the file. Fire a web-browser and type the url:
Sample outputs:

Fig.01: Apc Memory Status and Hit Ratio

From the above graph I’m getting 100.0% hit ratio and I’ve used almost all memory. I need to increase memory and reduce ttl value so that I will not get memory allocation error.

  1. PHP APC documentation.

🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 9 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
9 comments… add one
  • Daniel Oct 24, 2012 @ 7:11

    Thanks for the detailed informations. This fix worked for me.

    Greetings from Germany

  • Arindam Biswas Dec 3, 2012 @ 12:49

    Thank you. Nicely written. Your good deed of the day!


  • Igor Jan 5, 2013 @ 19:22

    Thank you for the explanation, it helped me to solve this problem.

  • Justin C. Feb 15, 2013 @ 15:03

    Worked for me! Thanks!

  • Nicram Mar 31, 2014 @ 12:02

    Great article. Today i saw same problem on my box and was trying to know what happen. It was first site and it work now. thank You!

  • rosh3000 Apr 8, 2014 @ 15:34

    Thank you. A little more explanation on how to interpreter the results in apc.php and what the graph should be like would be very useful.

  • Hưng May 26, 2015 @ 4:47

    Thank you, Unbelievable your helped!

  • robin Aug 31, 2015 @ 8:01

    Worked for me! Thanks!

  • anton Dec 28, 2015 @ 2:44

    nice explain. thanks

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum