## Summary

*"Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 20480 bytes)"* means a PHP process on your WordPress site hit its memory ceiling and was killed. You see it as a white screen, a "There has been a critical error on this website" message, a half-loaded admin, a failed plugin update, a stuck import or a checkout that dies at the last step. The byte number in the message is your current limit: 41943040 is 40M, 67108864 is 64M, 134217728 is 128M and 268435456 is 256M.

This guide gives you the fast isolation steps first. If you would rather hand it over, SazM offers an affordable, low-cost WordPress memory exhausted fix for a **fixed $99 price, delivered within 48 hours**, entirely in writing: no calls, no project manager, one senior developer.

## Where the Error Lives

The message names the file and line that was running when memory ran out. That is the first clue, but not always the culprit: it is only the code that asked for the last few bytes. Check these places:

```text
wp-content/debug.log              # when WP_DEBUG_LOG is on
/var/log/php-fpm/error.log        # path varies by host
/var/log/apache2/error.log        # or /var/log/nginx/error.log
wp-config.php                     # WP_MEMORY_LIMIT, WP_MAX_MEMORY_LIMIT
php.ini or .user.ini              # memory_limit
```

A typical line looks like this:

```text
PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 65536 bytes) in /wp-content/plugins/example/includes/class-export.php on line 212
```

Note whether it happens on one page, in wp-admin only, during a cron run or during an import. Each points to a different cause.

## Quick Fix Breakdown (DIY)

- **Read the limit PHP really uses.** WordPress and PHP each have a setting, and the host can override both:

```bash
wp --info                       # shows the PHP binary and ini files
php -i | grep -E "memory_limit|Loaded Configuration"
wp eval 'echo ini_get("memory_limit");'
```

The CLI value can differ from the web value, so also create a temporary page that prints `ini_get('memory_limit')` through the web server, then delete it.

- **Raise the limit to a sensible value, not a huge one.** In `wp-config.php`, above the line that says "That's all, stop editing":

```php
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '512M' ); // wp-admin and heavy tasks only
```

`WP_MEMORY_LIMIT` cannot exceed what PHP allows. If the value does not change, set `memory_limit = 256M` in `php.ini` or `.user.ini`, or in your hosting panel's PHP settings, then restart PHP-FPM or wait for the `.user.ini` cache to refresh. On Apache with mod_php only, `php_value memory_limit 256M` works in `.htaccess`; on PHP-FPM that line causes a 500 error.

- **Find what is eating memory instead of only raising the cap.** Turn on logging without showing errors to visitors:

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

- **Isolate the plugin or theme.** On a staging copy, deactivate everything and switch on one at a time:

```bash
wp plugin list --status=active
wp plugin deactivate --all
wp theme activate twentytwentyfour   # any default theme you have installed
```

- **Check the usual heavy hitters:** page builders with large templates, backup and security scanners running on web requests, image optimisers, WooCommerce reports, broken cron loops and big imports. Run imports and bulk jobs through WP-CLI, which has no web timeout, instead of the browser.
- **Look at the database, not only PHP.** Huge autoloaded options slow and bloat every request:

```bash
wp db query "SELECT SUM(LENGTH(option_value)) AS bytes FROM wp_options WHERE autoload='yes';"
```

Use your own table prefix. Several megabytes of autoloaded data is a red flag.

- **Memory leaks do not cure themselves.** If raising the limit only delays the crash from 128M to 256M to 512M, a plugin is looping or loading an unbounded query. Raising the cap again just moves the failure and can exhaust the whole server.

If none of these isolates it within an hour, stop. Every extra hour is lost orders and lost search ranking.

## Hand It Over: $99 Fixed, Within 48 Hours

Memory errors drag on because the cause is split three ways: the host's real limit, the code that asks for too much, and the data it loads. One developer who checks all three ends the guessing.

What you get for **$99**:

- **A fixed price agreed before work starts.** One issue, one flat fee, no hourly meter.
- **Delivery within 48 hours** of access, with the fix verified on staging before anything touches production.
- **Fully written, fully async.** You send the URL, the page or action that fails, the exact error line and what changed recently (plugin update, PHP upgrade, new host, import). You get questions, progress and proof in writing. There are no calls, meetings or project managers.
- **Written proof it works:** the root cause in plain language, which plugin, setting or query was responsible, a before and after check, and a rollback note.
- **Money-back guarantee** if the agreed root cause cannot be resolved.
- **Safe access only:** a limited SSH, hosting or WordPress admin account that you can revoke. Never send passwords through the inquiry form.

If the site shows a full white screen after an update, see [WordPress crash recovery after a plugin update](/articles/wordpress-crash-recovery-after-plugin-update). If the problem is slow pages rather than a fatal error, see [Core Web Vitals, INP and LCP remediation](/articles/core-web-vitals-inp-lcp-remediation).

Behind it: 20+ years in production (since Oct 2006) and 100+ projects in the portfolio.

**[Get this error fixed for $99 →](/bug-fix-services)** · [Queue an urgent fix](/checkout/emergency) · [See past projects](/projects)

## Frequently Asked Questions

### What does "Allowed memory size exhausted" mean in WordPress?
A PHP process tried to use more memory than its configured limit and was stopped. The number in the message is the limit in bytes, for example 268435456 bytes is 256M. The file named in the message is where PHP ran out, not necessarily the plugin that caused it.

### How do I increase the WordPress memory limit?
Set `WP_MEMORY_LIMIT` and `WP_MAX_MEMORY_LIMIT` in `wp-config.php`, and raise `memory_limit` in `php.ini`, `.user.ini` or your hosting panel. WordPress cannot go above what PHP allows, and some hosts cap it regardless of your settings.

### Is raising the memory limit a real fix?
Only when the site genuinely needs more memory, such as a large import or a big WooCommerce catalogue. If the error returns after each increase, a plugin or query is leaking or looping, and the root cause needs fixing.

### Why does the error appear only in wp-admin or during an import?
Admin screens and bulk jobs load far more data than front-end pages and use the higher `WP_MAX_MEMORY_LIMIT`. Heavy plugins, large media libraries and big imports hit the ceiling there first. Running the job through WP-CLI often avoids it.

### How much does it cost to fix a WordPress memory exhausted error?
SazM fixes one issue for a fixed $99, delivered within 48 hours, with a money-back guarantee if the agreed root cause cannot be resolved. Typical agency hourly rates are higher and open-ended, while very low marketplace gig prices rarely include root-cause diagnosis, a staging test or a guarantee.
