How to Solve PHP Warning Unable To Allocate Memory For Pool


Symptoms

During the PHP script execution, one of the next warnings occurs:

require(): Unable to allocate memory for pool.
require() [function.require]: Unable to allocate memory for pool.
require_once(): Unable to allocate memory for pool.
require_once() [function.require-once]: Unable to allocate memory for pool.
include(): Unable to allocate memory for pool.
include() [function.include]: Unable to allocate memory for pool.
include_once(): Unable to allocate memory for pool.
include_once() [function.include-once]: Unable to allocate memory for pool.

Cause

The typical cause of this problem is an improperly configured PHP caching framework like APC (Alternative PHP Cache) that is used to optimize website execution by caching intermediate code.

Requirements

Before you start, please make sure that you have the ability to perform the following actions on your web server. Otherwise consider contacting your website hosting provider for assistance.

  • Modify php.ini file (PHP configuration file)
  • Restart Apache web server (to apply php.ini changes)

Read Me First

Based on the official PHP documentation, the APC caching framework is no longer maintained. Consider avoiding use of this module on your web-server and replace it with alternatives such as OPcache, APCu or Windows Cache for PHP.

Please note: The only solution for this issue is to allocate more memory for the caching mechanism. This should not be considered as a permanent solution because the same problem may occur again in the future even with an increased memory limit. The best solution is to profile and then refactor/optimize your website code.

Resolution

Open your web server’s php.ini file and locate the [apc] section (if it does not exist, you can add one at the bottom of the file). Reconfigure the APC module to allocate more memory for caching using the settings below:

[apc]
apc.enabled=1
apc.shm_size=256M
apc.num_files_hint=1024
apc.enable_cli=0

The complete list of APC configurations can be found here.

Fix WordPress PHP errors instantly with CodePinch!

Get Started
Thank You! Message Submitted Successfully!