Loading...


Related Products


Date Published: February 6, 2025

Troubleshooting the error "Allowed memory size of X bytes exhausted"

Issue

When accessing some pages on your site, running a Drush command on the server or in a cron job, you might face this error:

[09-Jul-2019 07:03:27 Europe/Paris] PHP Fatal error:  Allowed memory size of XXXXXXXX bytes exhausted (tried to allocate XXXXX bytes) in /full/path/to/module/page.php on line 2703 request_id="v-0000zzzz-a1b2-0000-c3d4-2703zzd0907"

This is usually due to PHP or Drupal not having enough resources to make the request. This means the global PHP memory limit is too low for a site which has overall higher complexity/rendering needs than a standard page.

As explained in the documentation "Conditionally increasing memory limits", some pages on your Drupal website (such as admin pages or reports) can require additional resources to run. Increasing these resources globally can decrease your website's overall performance.

 

Resolution

As a short-term workaround, you can either:

  • Raise the overall available memory on your environment via the Cloud UI (see Configuring PHP memory limit). 
    • If you are running on Cloud Platform, you can increase the available memory in this way.
    • However, if you are running on Cloud Classic architecture, this can lower the available concurrent requests your site can handle.
  • Add a snippet in your settings.php that will allocate additional memory resources for a specific path or URL, or for Drush runs. Those snippets are listed in this documentation: "Conditionally increasing memory limits".

 

Longer-term, you should learn more about how your site uses PHP memory, and make adjustments appropriately. We recommend reading through this article: How to investigate Memory Consumption problems.

In summary:

  • Find the regular memory consumption of your site. Usually "light" pages would use between 10-30MB of memory on the server. See if you have some sections (like the homepage, Search pages, or Views) that use up more memory.
  • To optimize memory-heavy sections, ask yourself if you can, for example: render less content, or show fewer items/blocks.

 

See the article How to investigate Memory Consumption problems for more.

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
Back to Site navigation