Activities

March 2015
M T W T F S S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

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

After enabling APC cache on one of the WordPress hosting, I got such errors displayed in application area.After the first lokk, it’s been identified that it is something related to memory pool allocation towards the application area.

What I found was,

I had set apc.shm_size to it’s default value 32Mb which will be filled up very quickly during the peach hours and hence application got such error ” PHP Warning: require_once(): Unable to allocate memory for pool”. So better approach is to increase it’s size and reduce the cache expiration time. So that cached files will be flushed out and can eliminate such issues.

Action taken

Since I’m using the combination of Ngnix and php-fpm settings to run the php application, we need to restart php-fpm service in order to take effect any php related settings.

a. Updated the values of apc.shm_size , apc.ttl and apc.user_ttl
apc.shm_size = 90MB
apc.ttl = 3600
apc.user_ttl = 3600

[root@ph-web01 ~]# cat /etc/php.d/apc.ini  | grep -E "apc.shm_size|apc.ttl|apc.user_ttl"
apc.shm_size=90M
apc.ttl=3600
apc.user_ttl=3600
[root@ph-web01 ~]#

b. Restart the php-fpm process

[root@ph-web01 ~]# /etc/init.d/php-fpm restart
Stopping php-fpm: [ OK ]
Starting php-fpm: [ OK ]
[root@ph-web01 ~]#

Also I observed the Both Nginx and php-fpm occupying memory for caching pages on long running period. So I would wish to released the those cached pages by restarting this web service at early morning of server time. So none of the users won’t be affected.

c. Enable Linux native mechanism to move all inactive cached pages from memory to disk cache.

So I set a cron for executing the command /bin/sync; echo “3” > /proc/sys/vm/drop_caches;

My root cronjobs is become as showing below,

[root@ph-web01 ~]#   crontab -l
00 */1 * * * /bin/sync; echo "3" > /proc/sys/vm/drop_caches;
00 03  * * * /etc/init.d/nginxd restart
05 03  * * * /etc/init.d/php-fpm  restart
[root@ph-web01 ~]#

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>