WordPress Memory Limit Error

Category: WordPress Hosting ยท Updated 2026-11-01

The WordPress memory limit error, shown as "Allowed memory size of X bytes exhausted", happens when a plugin, theme or import process asks PHP for more memory than it is allowed to use. The fix is almost always to raise the PHP memory limit through wp-config.php, php.ini or your host's control panel, and to check whether a specific plugin is the real cause.

What the error actually means

PHP, the language WordPress runs on, enforces a per-request memory_limit so a single runaway script cannot use all the server's RAM. When a page needs more than that limit, PHP stops the script and shows an error such as:

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /wp-content/plugins/example/file.php on line 42

The number in bytes is the limit itself (134217728 bytes is 128 MB). This is different from the server's total physical RAM; it is a ceiling set just for PHP, and it can be raised without buying more hardware, up to whatever your hosting plan allows.

Common causes

  • A plugin or theme with inefficient code that loads too much data into memory at once.
  • Large imports or exports, such as migrating products or posts in bulk.
  • Image editing operations through the GD or Imagick PHP libraries on very large photos.
  • Too many active plugins doing overlapping work on every page load.
  • A hosting plan with a low default PHP memory limit, sometimes as low as 32 MB or 64 MB.

How to raise the WordPress memory limit

WordPress has its own setting, WP_MEMORY_LIMIT, which tells PHP how much memory the main site can use, separate from a higher limit for admin screens. Add this line to wp-config.php, above the line that says /* That's all, stop editing! */:

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

If the error still appears, the server-wide PHP limit may be lower than what WordPress is requesting. That limit is set in php.ini, or in an .htaccess line such as php_value memory_limit 256M on Apache servers that allow it, or through a PHP settings panel most hosts provide. Many control panels let you pick the memory limit per site without editing files directly.

Typical memory needs by site type

Site typeUsually enough
WordPress core aloneAbout 40 MB
Typical theme with a handful of plugins128 MB
Page builders, WooCommerce, SEO plugins together256 MB
Large imports, bulk image processing512 MB or more, often temporarily

When raising the limit is not enough

If the error returns even after raising the limit, treat it as a symptom rather than fixing it blindly. Deactivate plugins one at a time to find which one is consuming excessive memory, check your host's PHP error log for the exact file and line, and consider replacing a heavy plugin rather than continually raising the ceiling. A hosting plan with a low fixed PHP memory cap that cannot be increased may also be a sign it is time to upgrade.

Frequently asked questions

What does "allowed memory size exhausted" mean in WordPress?

It means a PHP script, usually triggered by a plugin, theme or import, tried to use more memory than the server's PHP memory_limit allows, so PHP stopped it and showed this fatal error.

How do I increase the memory limit in WordPress?

Add define( 'WP_MEMORY_LIMIT', '256M' ); to wp-config.php above the "stop editing" line. If the error persists, the host's server-wide PHP memory_limit also needs to be raised, usually through php.ini or a hosting control panel.

What is the default WordPress memory limit?

WordPress itself requests 40 MB for a single site and 64 MB for multisite by default if WP_MEMORY_LIMIT is not set, but the actual limit used is whatever the server's PHP memory_limit allows, which varies by host.

Why do some plugins need so much memory?

Plugins that process images, generate PDFs, import large files or run complex queries load more data into memory at once than a simple page. Poorly optimized code can also use far more memory than necessary for the same task.

Will raising the memory limit fix every WordPress error?

No. It only fixes errors that explicitly mention memory being exhausted. Other fatal errors, white screens or timeouts can have unrelated causes such as a PHP version conflict or a script that runs too long.

Can shared hosting support a higher memory limit?

Many shared hosting plans allow memory_limit increases up to a plan-specific cap, often 256 MB or so, through a control panel setting. If your plan caps it lower and a legitimate plugin needs more, upgrading to a higher plan or a VPS is usually the next step.

Related topics