Skip to content

Fixing the 'Unable to allocate memory for pool' PHP error message

When running PHP applications, you may encounter the error:

Unable to allocate memory for pool

This typically occurs when the APC (Alternative PHP Cache) configuration is not properly tuned for your hosting environment.

  • APC is used to cache PHP bytecode in memory.
  • If APC’s memory pool is too small, PHP cannot allocate enough memory.
  • Misconfigured APC settings can trigger this error.
  • This error requires adjustment of APC configuration settings at the server level.

  • Open a Support ticket

  • Provide:

    • The complete error message.
    • A reference to this Knowledge Base article.

Step 2: Verify APC Settings (Advanced Users on VPS/Dedicated)

Section titled “Step 2: Verify APC Settings (Advanced Users on VPS/Dedicated)”

If you manage your own VPS or Dedicated server, you can adjust APC settings in php.ini:

apc.enabled = 1
apc.shm_size = 128M
apc.num_files_hint = 1000
apc.ttl = 7200
apc.user_ttl = 7200
apc.gc_ttl = 3600
  • Increase apc.shm_size to allocate more shared memory.
  • Adjust apc.num_files_hint based on the number of PHP files your application uses.

Restart Apache after making changes:

service httpd restart # AlmaLinux/Fedora
service apache2 restart # Debian/Ubuntu
  • Use the APC status script (apc.php) to monitor cache usage.
  • Ensure cache hit rates are high and memory fragmentation is low.
  • Adjust settings further if needed.