“Allowed memory size exhausted” in WordPress

What the WordPress memory exhausted error means, how to raise WP_MEMORY_LIMIT within PHP’s limit, and how to find what’s using the memory.

TroubleshootingIntermediate2 min readUpdated

Does this match what you’re seeing?

  • The log shows ‘Allowed memory size of ... bytes exhausted’
  • Imports, backups or image uploads fail partway
  • A critical error appears on specific pages

PHP gives each request a memory budget. The error means one request tried to use more.

PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)

134217728 bytes is 128MB.

1. Raise WordPress’s own limit

WordPress sets its own limit, which can be lower than PHP’s. In wp-config.php, above /* That's all, stop editing! */:

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

WP_MAX_MEMORY_LIMIT applies to admin tasks.

2. Check PHP’s limit

WordPress can’t exceed PHP’s memory_limit. Check it under Tools → Site Health → Info → Server. If it’s the lower of the two, see whether it can be raised for your account. Changing PHP settings: memory_limit, upload size and execution time

3. Find what’s using the memory

Raising limits treats the symptom. On a typical site, high memory use comes from:

  • an import or export processing too much at once — split it into batches
  • image processing on very large uploads — resize before uploading
  • a specific plugin — the error’s file path usually names it
  • a backup plugin creating archives in PHP — schedule off-peak or use DirectAdmin backups instead

If a site repeatedly needs ever-higher limits, one component is at fault. Why is WordPress slow? How to find and fix the cause

Choosing somewhere to host WordPress? Traxio’s WordPress hosting includes one-click installs, LiteSpeed caching and free SSL, with your first 30 days free.

Popular

Tip: press / to search from any pageSee all results