Get a free website with any plan

See how
WORDPRESS

Fixing WordPress "allowed memory size exhausted" errors

IN SHORT

WordPress hits "allowed memory size exhausted" when a script needs more RAM than PHP allows. Fix it two ways: raise WP_MEMORY_LIMIT in wp-config.php, and find what's actually consuming the memory, since a higher limit alone only delays the next crash.

The fix is two-part: raise WP_MEMORY_LIMIT in wp-config.php so WordPress can request more memory, and find out what's actually consuming it, because a higher limit without fixing the cause just delays the next crash.

The full error usually reads something like Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /path/to/file.php on line 123. That number is bytes, not a setting name. 268435456 bytes is 256MB. Whatever number you see, it tells you the ceiling WordPress hit.

WP_MEMORY_LIMIT vs PHP's memory_limit

There are two different memory limits at play, and mixing them up wastes time.

  • PHP's memory_limit is a server-level setting. It caps how much memory any PHP script is allowed to use, WordPress or not. This is set at the PHP level, not in WordPress files.
  • WP_MEMORY_LIMIT is a WordPress-level constant defined in wp-config.php. It sets the memory ceiling WordPress itself requests, but it can't exceed what PHP's memory_limit allows. Raising WP_MEMORY_LIMIT past the PHP ceiling does nothing: PHP still enforces its own limit underneath.

Check what your account's PHP memory_limit is actually set to before you touch anything else. Create a file called phpinfo.php in your site root with:


Visit it in your browser, search the page for memory_limit, then delete the file when you're done (never leave a phpinfo() file sitting on a live site). If your WP_MEMORY_LIMIT is already at or above that PHP ceiling, raising it further in wp-config won't help. Open a ticket via Support → New ticket in the portal if you need the PHP-level limit raised.

Raise WP_MEMORY_LIMIT in wp-config.php

Open wp-config.php via FTP or the file manager. Add this line before the /* That's all, stop editing! */ comment:

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

If a lower value is already defined, raise it. Common steps are 256M, then 512M if the error persists. There's also WP_MAX_MEMORY_LIMIT, which controls the ceiling for admin-side processes like the Dashboard and cron, separate from front-end pages:

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

Reload the site or the admin action that was failing. If the error is gone, you've bought headroom, but that headroom disappears again as content and plugins grow. Treat this as a stopgap, not a fix.

Find what's actually eating the memory

A memory exhaustion error is a symptom. Something is allocating more than it should, and it's worth finding before it happens again at a higher limit.

  • Deactivate plugins one at a time. If the error only happens on a specific admin screen or during a specific action (saving a post, running an import, generating a report), that narrows the suspect list fast. Deactivate half your plugins, test, then bisect from there.
  • Look at what you were doing when it happened. Bulk imports, PDF or image generation, large exports, and report-building plugins are frequent causes. These load large datasets into memory at once.
  • Check recently updated or added plugins. A plugin update that introduced a memory leak or a new heavy dependency is a common trigger for an error that "started happening out of nowhere."
  • Enable WP_DEBUG_LOG temporarily to capture the exact file and line from the error, which often names the plugin or theme function responsible.

Heavy plugins are also a general performance drag even when they don't cause a hard crash. If your site feels sluggish beyond just this error, My WordPress site is slow covers auditing plugin weight and image handling in more depth.

PHP version matters too

Newer PHP versions handle memory more efficiently than older ones. If you're running an old PHP version for legacy plugin compatibility, that's worth weighing against the memory savings a modern version offers. See What PHP version should I use for WordPress? for how to check and switch from the PHP tile.

When it's not a plugin problem

If the memory error started right after a WordPress core update, a theme update, or shows up alongside database connection issues, the cause may sit outside plugin territory. A site that can't reach its database will throw a different error, covered in Fixing WordPress database connection errors, but it's worth ruling out if errors are stacking up together.

Also worth checking before you assume it's a rogue plugin: a corrupted database table or a runaway query can inflate memory use during otherwise normal page loads. If repair steps are relevant, they're covered in the database connection article above.

When to contact support

If you've confirmed the PHP memory_limit itself is the ceiling (not WP_MEMORY_LIMIT) and you need it raised, or if you've isolated the problem to something server-side rather than a specific plugin, open a ticket via Support → New ticket in the portal. Include the exact error text with the byte number, and mention what you were doing when it happened. A real person will look at it, and if it needs a server-level change, that's on us to make.

Common questions

What does the memory size exhausted error actually mean?

It means a PHP script tried to use more memory than the server allows and hit the ceiling. The byte number in the error (like 268435456, which is 256MB) tells you what that ceiling was, not a setting you need to type in anywhere.

How do I raise the WordPress memory limit?

Add define('WP_MEMORY_LIMIT', '256M'); to wp-config.php before the "stop editing" comment. If the error persists, try 512M, but check that PHP's own memory_limit isn't capping you first, since WP_MEMORY_LIMIT can't exceed it.

What's the difference between WP_MEMORY_LIMIT and PHP's memory_limit?

PHP's memory_limit is a server-level setting that caps every PHP script, WordPress or not. WP_MEMORY_LIMIT is a WordPress constant in wp-config.php that requests memory within that PHP ceiling, so raising it past the PHP limit does nothing.

Why does the error keep coming back after I raise the limit?

Because raising the limit is a stopgap, not a fix. Something is still consuming excess memory, often a plugin, a bulk import, or a report-building tool, and that headroom disappears again as content and plugins grow.

How do I find which plugin is causing the memory error?

Deactivate plugins one at a time and test, or deactivate half and bisect from there. Enabling WP_DEBUG_LOG temporarily captures the exact file and line, which often names the plugin or theme function responsible.

CAN'T FIND IT?

Real humans answer fast.

Hosting with us? Open a ticket and a real person replies - no scripts, no upsells. Still choosing a host? The same team is included with every plan, from day one.