Maintenance

"Allowed Memory Size Exhausted" in WordPress: Causes and Fixes for Memory Limit Errors

What "Allowed memory size exhausted" and other WordPress memory errors mean, how to check PHP memory and WP_MEMORY_LIMIT, and how to fix the real cause.

"Allowed Memory Size Exhausted" in WordPress: Causes and Fixes for Memory Limit Errors
On this page
  1. What the error means
  2. Other memory errors you might see
  3. Common causes
  4. Check your current limits
  5. How to fix it
  6. When hosting is the real problem
  7. Stop it happening again
Key takeaways
  • "Allowed memory size exhausted" means a page needed more PHP memory than allowed; the file named is a clue, not always the cause.
  • Check your PHP memory limit and WP_MEMORY_LIMIT in Site Health, then raise them in wp-config.php and your hosting panel.
  • If pages need far more than 256M, find the heavy plugin, import or oversized image instead of raising the limit again.

If your site shows "There has been a critical error on this website" and the error log mentions "Allowed memory size of 134217728 bytes exhausted", WordPress ran out of the memory it's allowed to use for that page. Raising the limit often gets the site back quickly, but it isn't always the real fix. Here's what memory errors mean, how to check your limits and how to deal with the cause.

What the error means

Each time a page loads, PHP (the language WordPress runs on) gives that request a fixed amount of memory. If WordPress, your theme and your plugins need more than that, PHP stops with a fatal error. Visitors see a critical error message or a blank white page, while the full message appears in your error log or in the email WordPress sends to the admin address.

A typical message looks like this: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /wp-content/plugins/some-plugin/file.php

  • The first number is the limit in bytes: 134217728 is 128 MB and 268435456 is 256 MB
  • "Tried to allocate" is only the last small request that tipped it over
  • The file named is where memory ran out, not necessarily what used it up. Treat it as a clue, not a verdict

For the full process of getting a site with a critical error back online, see how to fix "There has been a critical error".

Other memory errors you might see

What you seeWhat it usually means
"Allowed memory size ... exhausted"The PHP memory limit for a single request was reached
"Out of memory (allocated ...)"The server couldn't provide more memory at all, usually a hosting account or server limit rather than the PHP setting
Errors only on certain admin screensA heavy task, such as a page builder editor, a large report or an import, needs more than normal pages
Image uploads failing with a message that the server can't process the imageResizing a very large photo needed more memory than was available
500 or 503 errors, or a "resource limit reached" page on shared hostingThe hosting account hit its overall limits, not just PHP's per-request limit

Common causes

  • A heavy or badly coded plugin that loads far more than it needs on every page
  • A plugin conflict or loop: two plugins interacting badly can eat memory until the limit is hit, often straight after an update
  • Page builders on very long pages with many sections and widgets, especially in the editor
  • Imports, exports and reports: WooCommerce product imports, large order exports and analytics screens
  • Backup plugins compressing a large site from inside WordPress
  • Very large images: phone photos uploaded at full size
  • A low limit set by the host on some budget plans
  • Malware: occasionally, injected code is behind sudden, unexplained memory use

Check your current limits

In the dashboard, go to Tools → Site Health → Info:

  • Server → PHP memory limit: the limit set on your hosting
  • WordPress Constants → WP_MEMORY_LIMIT: the memory WordPress asks for on normal pages
  • WordPress Constants → WP_MAX_MEMORY_LIMIT: the memory WordPress asks for during heavier admin tasks

WordPress tries to raise PHP's limit to match these settings, but many hosts set a cap it can't go past. If changing the WordPress setting makes no difference, the limit has to be raised on the hosting side.

How to fix it

1. Get the site back online

If visitors can't see the site, use the recovery mode link in the admin email, or deactivate the plugin named in the error by renaming its folder. Take a backup before changing anything else.

2. Raise WordPress's memory setting

Add this line to wp-config.php, above the comment that begins "That's all, stop editing!":

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

256M is a sensible setting for most business sites. If errors only happen in the dashboard, for example during imports or updates, WP_MAX_MEMORY_LIMIT controls admin tasks and can be set the same way. Ask your developer if you're not comfortable editing this file.

3. Raise the PHP limit at your host

Most control panels let you change PHP options, including memory_limit, in a section such as "Select PHP Version", "MultiPHP INI Editor" or PHP configuration. If you can't find it, ask your host's support team. Some guides suggest editing .htaccess or php.ini instead; that only works on certain server set-ups and can cause a 500 error, so prefer the control panel.

4. Find what's actually using the memory

If normal pages need far more than 256M, raising the limit further only hides a problem that will come back. Instead:

  • Check the error log to see which plugin files keep appearing
  • Use the free Query Monitor plugin on a staging copy to see peak memory use for each page
  • Deactivate plugins one at a time on staging until usage drops; see staging sites explained
  • Replace heavy or abandoned plugins, split very long builder pages and run big imports in smaller batches
  • Resize photos before uploading them

When hosting is the real problem

On budget shared plans, the PHP limit may be low and the account's total memory is shared by every visitor and background task. Signs you've outgrown your plan include memory errors that return during busy periods, a sluggish dashboard, backups that fail partway and resource warnings in your hosting panel. Sometimes a better plan or host is the right fix; see how to choose WordPress hosting in India.

Stop it happening again

  • Test plugin and theme updates on staging before applying them to the live site
  • Keep your plugin list lean and remove anything you don't use
  • Keep PHP on a current, supported version
  • Review error logs as part of monthly maintenance, so warnings are caught before visitors see errors

Seeing memory errors or a critical error right now? I fix broken WordPress sites and track down the plugin or setting behind the problem; see WordPress maintenance and support.

Need help with your website?

I'm Sameer, a freelance WordPress developer building fast, SEO-friendly websites since 2020. Tell me what you need and I'll reply with a plan and a fixed quote within 24 hours.

Found this useful? Share it:
Contact

Let's build your next website

Available for freelance projects, agency white-label work and long-term maintenance. Feel free to pass this along to your team or company.

Your details are emailed to me, then WhatsApp opens so we can chat right away.

Chat now