PHP Errors

Allowed Memory Size of 268435456 Bytes Exhausted (256 MB): What to Do

By ErrorNest Published Updated 5 min read
268435456 bytes is a 256 MB PHP limit. If you already raised it, find the plugin or task using the memory before raising it again.
Gaming motherboard showing its memory slots and expansion slots
Photo: PantheraLeo1359531, CC BY 4.0, via Wikimedia Commons
On this page

The error Allowed memory size of 268435456 bytes exhausted means PHP stopped a script that tried to use more than 256 MB (256 × 1024 × 1024 = 268435456 bytes). If you already raised the limit to 256 MB to fix the 128 MB version of this error, simply raising it again usually hides the real problem. At this size, something is using far more memory than a normal request, and finding it matters more than the number.

If you got here by doubling the 128 MB limit, the sum is 134217728 * 2 = 268435456 bytes, which is exactly 256 MB.

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes) in /home/user/public_html/wp-content/plugins/example/file.php on line 88

Quick fix: Note what you were doing when the error appeared, deactivate the plugin named in the file path, and test again. To confirm that memory is the only problem, you can temporarily allow 512 MB (step 4).

Why this number often appears in the WordPress dashboard

WordPress raises its own limit to 256 MB in the admin area by default, through a setting called WP_MAX_MEMORY_LIMIT. That is why many sites see 268435456 bytes in dashboard errors even though visitors see no problem. It tells you a dashboard task, such as an import, a plugin screen or an update, used more than 256 MB.

1. Note what triggered it and read the path

Write down the action that caused the error: opening a plugin screen, running an import, uploading images, a scheduled task, or visiting one particular page. Then read the file path in the message. A folder under wp-content/plugins/ or wp-content/themes/ points to the culprit.

2. Turn on the error log

Add these lines to wp-config.php, above the comment that says to stop editing:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Repeat the action that failed, then open wp-content/debug.log. The log shows the file and line and, often, the sequence of functions that led there. Remove these lines afterwards.

Memory slot for laptop DDR4 SO-DIMM modules on a motherboard
Photo: D-Kuru, CC BY-SA 4.0, via Wikimedia Commons

3. Deactivate suspect plugins

Deactivate the plugin named in the path and repeat the action. If you cannot tell which plugin it is, deactivate all plugins, confirm the error is gone, then reactivate them one by one. If you cannot reach the dashboard, rename the wp-content/plugins folder to plugins-off using File Manager or FTP.

4. Temporarily allow 512 MB to confirm

To check whether a task simply needs more memory, add these lines to wp-config.php:

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

The first line applies to visitor requests and the second to the dashboard. Many hosts cap memory below this value, so check Tools > Site Health > Info > Server to see the limit that is actually in force. If the task now succeeds, it needs a lot of memory and you should either reduce what it does or move to a plan with more memory.

5. Look for runaway code

A loop that never ends, or a function that keeps calling itself, will use all the memory you give it, however large the limit. If the error began right after you added a code snippet or edited functions.php, undo that change first.

6. Reduce what the page loads

Code that loads every post, order or user into memory at once will fail on a large site. Showing results in pages, for example 20 at a time, and avoiding unlimited queries keeps memory use steady. If a plugin does this, look for a setting that limits the number of items, or ask its developer.

7. Check images and uploads

Resizing very large photos needs a lot of memory. WordPress scales images wider than 2560 pixels down automatically, but huge files can still fail. Resize photos before uploading, and avoid uploading many large images at once.

8. Split imports, exports and backups

Importing a huge file, exporting a large store or backing up everything in one request can use all available memory. Split the job into smaller batches or run it at a quiet time. Some tools can be run from the command line, where memory settings can differ from the web server’s.

9. Measure memory use

The free Query Monitor plugin shows peak memory use for each page and lists the slowest queries and plugins involved. Use it on a staging copy if you can, because it adds some overhead.

10. Ask your host or upgrade

If a task genuinely needs this much memory, for example a large WooCommerce store or heavy page builder, ask your host what they allow, enable an object cache if they offer one, or move to a plan with more resources.

Frequently asked questions

Is 256 MB not enough for WordPress?

It is enough for most sites. If a request needs more than that, something is unusually heavy or a plugin has a bug.

Is this a memory leak?

Sometimes. A script that keeps allocating memory without releasing it will exhaust any limit. If raising the limit only delays the error, suspect a plugin or code problem.

Why does the error appear only in the dashboard?

Dashboard tasks such as imports, updates and plugin pages use more memory than a normal page view, and WordPress gives them a higher limit that they can still exceed.

When to contact support

If a specific plugin always triggers the error, send its developer the file path and line from the log. If your host will not allow more memory, ask whether another plan or a different PHP setup is available. For the same error at a lower limit, see the 134217728 bytes (128 MB) guide, or read the general memory error guide.

Official resources