4

I was getting tons of Warnings in my production site. like

PHP: Require_once(): Unable To Allocate Memory For Pool

I know its caused by APC and after I increased the shm_size and decreased the gc_ttl its gone. but my query is how come it displayed that warning in the web page? I have disabled display PHP errors and Just log it and it doesn't display any PHP errors in website.

To test this, I deliberately created a script which would throw PHP Warning and Notices, and yes up to my satisfaction these are just logged, NOT Displayed like APC error.

So, how do I disabled APC Warnings in Production site? (in case if it happens again)

  • try setting it via php.ini . If you restart your httpd, the problem might be gone anyway.. :) – Gogol Aug 07 '14 at 09:22
  • try what setting exactly? in php.ini `display_errors = Off` already –  Aug 07 '14 at 09:25
  • 1
    I did some research and it seems that this can't be turned off via php.ini. I can't find a setting to turn off error, in apc.ini either. So, I guess you should fix it ^_^ http://stackoverflow.com/a/3723338/1437261 – Gogol Aug 07 '14 at 09:34
  • Good question by the way. Upvoted :) – Gogol Aug 07 '14 at 09:36

1 Answers1

0

I think you should edit apc.ini not php.ini in conf.d directory. Checkout php.ini where is apc.ini used using phpinfo().

Check out is that exists and correct mask in directory (mask is "XXXXX"):

apc.mmap_file_mask=/tmp/apc.XXXXXX

Increase a memory to:

apc.shm_size=96M

Set memory time to live settings:

apc.ttl=3600

And temporary cache increase:

apc.gc_ttl=3600

Reload your apache/nginx.

After that you need to find memory usage and set apc.ttl and apc.shm_size. Copy /usr/share/php-pecl-apc/apc.php to our www project and run via browser apc.php.

Edit apc.php administrator password in apc.php:

defaults('ADMIN_PASSWORD','type-here-admin-password');

Save and run via browser. Then find Hits in File cache information to cheeck is used almost memory.

Reduce ttl value from above so you don't got memory error.

Marin Sagovac
  • 3,932
  • 5
  • 23
  • 53
  • thanks for taking your time to respond, but your answer doesn't really satisfy my question. I know if I set `apc.ttl=0` then I will never get that memory error as `apc` will always reload the cache, but that's not effective way. I want `apc` to **work under the hood** and log the error/warnings/notices instead of displaying it. –  Aug 22 '14 at 09:13
  • You should never set `apc.ttl=0` because APC will flush all cache when it's out of memory. Make your script of APC to check is 30% free available of APC memory every 1 hour. If you don't have memory change apc cache using script. Look at this line https://github.com/khoaofgod/phpfastcache/blob/Stable-Version-1.x/phpfastcache_v1.3_stable/php_fast_cache.php#L1190 and set you time limit for APC store. Did you set up this? – Marin Sagovac Aug 24 '14 at 17:20