Fix "Allowed Memory Size Exhausted" PHP Errors Print

  • 0

This error means a PHP script tried to use more memory than it's allowed. You'll usually see it as a message like Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes), or as a blank page or "critical error" message in WordPress. The number is the current limit in bytes (134217728 bytes is 128 MB).

1. Raise the PHP memory limit

  1. Log in to cPanel and go to Software › Select PHP Version.
  2. Open the Options tab (if it says the native version is selected, choose a numbered version first).
  3. Choose a higher value for memory_limit. It saves automatically.
  4. Reload the page that showed the error.

Full details are in how to change PHP limits.

2. For WordPress, check WP_MEMORY_LIMIT

WordPress has its own memory setting, which can be lower than PHP's. If the error continues after raising memory_limit, open wp-config.php in Files › File Manager and add this line above the one that says /* That's all, stop editing! */:

define( 'WP_MEMORY_LIMIT', '256M' );

Use a value no higher than the memory_limit you set in cPanel; WordPress can't use more than PHP allows.

3. Find what's using the memory

Raising the limit fixes the symptom, but a well-behaved site rarely needs a very high limit. If the error keeps coming back, something is probably using far more memory than it should:

  • A plugin or theme: the error message names the file that ran out of memory. If the path includes wp-content/plugins/plugin-name, that plugin is the likely cause. Update it, or deactivate it to test.
  • A recent update: if the error started straight after an update, see why a site breaks after a WordPress update.
  • Large tasks: imports, image processing and backup plugins can use a lot of memory. Run them at a quiet time, or in smaller batches.

Can't get into WordPress to deactivate a plugin? In File Manager, rename its folder in wp-content/plugins (for example add -off to the end); WordPress then treats it as deactivated.

Still seeing the error?

Your account also has an overall resource allowance, so a single script can't use more memory than your plan provides, whatever memory_limit says. If you've raised the limit and ruled out plugins, open a support ticket with the full error message and the page where it appears.


Was this answer helpful?

« Back