Loading...


Related Products


Date Published: February 6, 2025

Finding/Resolving Memory Related PHP errors in Acquia Cloud

Issue

How can I fix PHP errors on my website?

Resolution

When it comes to performance tuning your Drupal application on Acquia Cloud and in other hosting environments; or, just figuring out why your site may be running slower than expected, there is a wealth of information that can be gleaned from your PHP errors log (php-errors.log), Drupal Watchdog log (drupal-watchdog.log) and FPM errors log (fpm-error.log). 

PHP Memory Limit errors 

The PHP memory limit is the maximum amount of RAM memory, in Megabytes (M), that a single PHP process can consume. Memory used by the MySQL client counts against the PHP memory limit. The default setting for PHP memory is adequate for most Drupal applications on Acquia Cloud, but you may see the following errors which are clear signs that the memory limit may be set too low. 

  • WSOD (White Screen of Death) errors, these are characterized by going to the page, and seeing a blank page (a blank white screen) with no error message. 
  • Temporary Unavailable errors - on a page, or on a site action, for example, uploading large files, or running long reports.
  • Check the php-errors.log for errors similar to this one: 
[20-Feb-2017 19:26:10 America/New_York] PHP Fatal error:  Allowed memory size of 268435456 bytes exhausted (tried to allocate 15990062 bytes) in docroot/includes/database/database.inc on line 2227

The best way to resolve these issues is within the application. Use How to investigate Memory Consumption problems to help you identify resource intensive areas of your application. We recommend making changes in your code to reduce the memory use; however, it can help to increase the PHP memory limit in some cases. This can be changed either through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in Configuring PHP Settings) or through a support ticket for Site Factory products.
 

PHP Max Execution Time

PHP Max Execution is the amount of time a single PHP process can run (in seconds). We recommend that you resolve this problem by identifying slow processes and refactoring the code that makes the request or set_time_limit() function.

Search the the fpm-error.log for max_children errors - which can indicate that the available PHP/FPM processes are consumed. This can also be indicated by Temporarily Unavailable, or White Screen of Death errors. 

Our Acquia Cloud Professional and Acquia Cloud Enterprise products can adjust PHP Max Execution time through the Acquia Cloud web site (Configuring max execution time).
 

PHP OPcache

OPcache is the cache for the pre-compiled bytecode. It is faster than using PHP to load and parse the PHP scripts that make up your Drupal application for each and every HTTP (HTTPS) request. The OPcache in PHP 7 should be set to be large enough to store compiled code for your applications' PHP scripts, but we recommend that you also set this value to be low enough to avoid allocating too much RAM to an underused cache. This is called APC in PHP 5.5 and below.

  • Check the php-errors.log for errors similar to this one:  
Warning: require_once() [function.require-once]: Unable to allocate memory for pool.

This value can be changed under APC memory settings (this is called APC in PHP 5.5 and earlier) through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in Configuring PHP Settings) or through a support ticket for our Site Factory customers. 

There is a tool available that will help you analyze what is in OPCache for your application: https://github.com/rlerdorf/opcache-status.
 

OPcache Interned Strings buffer 

The Interned Strings buffer is the amount of memory (in Megabytes (M)) used to store identical strings (detected by PHP). By default, this is a shared buffer allowing all Drupal PHP processes to reference it across multiple PHP/FPM processes - saving memory.

Current Drupal version applications, in general, make greater use of the interned strings buffer, we recommend that you check the fpm-error.log for the following type of error:

[23-May-2017 18:53:47] WARNING: [pool sitegroupname] child 19109 said into stderr: "Tue May 23 18:53:47 2017 (19109): Warning Interned string buffer overflow"

This value can be changed under OPcache interned strings buffer through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in OPcache interned strings buffer) or through a support ticket for our Site Factory customers.
 

APCu or APC user_cache errors

APC User cache is PHP the part of APC that is not a part of OPcache. It was rarely used in Drupal 7  (for example, the default Acquia Value, apc.shm_size=8M, is okay for most sites).  

In general, current Drupal version sites make much greater use of the APC user cache. For a single web site, we recommend increasing the PHP user cache, apc.shm_size=16M, or the default PHP value of 32M. If you are using our Site Factory applications, or a larger multi-site, you may need to increase the APC user_cache setting even further.   

A clear sign that the APC User cache is set too small is this type of error in your php-errors.log

[20-Feb-2017 13:54:16 America/New_York] PHP Warning:  apcu_store(): Unable to allocate memory for pool. in /mnt/www/html/somenamedev/docroot/core/lib/Drupal/Core/Cache/ApcuBackend.php on line 177

Having your application try to allocate too much information in a small cache can result in slow site performance, and 'hung' PHP/FPM processes that cause your site to fail. 

This value can be changed under APCu size through the Acquia Cloud web site for our Acquia Cloud Professional and Acquia Cloud Enterprise products (more information in APCu size) or through a support ticket for our Site Factory customers. 

See this article How to monitor and tune APCu for additional tips and tools to improve the performance of your application.

Further Reading

See the following references for information about how to find, and search through your log files: 

Did not find what you were looking for?

If this content did not answer your questions, try searching or contacting our support team for further assistance.

Back to Section navigation