Home › Web Platform › WordPress Memory Exhausted Error: Raise the Limit
Beginner 5 min · September 23, 2026

WordPress Memory Exhausted Error: Raise the Limit

Raise WP_MEMORY_LIMIT to 256M first — WordPress memory errors come from plugin bloat, a low PHP ceiling, or capped hosting plans..

N
Naren Founder & Principal Engineer

20+ years shipping production backend systems. Everything here is grounded in real deployments.

Follow
✓ Production
production tested
September 27, 2026
last updated
2,085
articles · all by Naren
Before you start⏱ 22 min
  • ✓Access to wp-config.php and the Site Health screen
  • ✓A staging clone for safe plugin memory testing
  • ✓Know your hosting plan's PHP memory cap
 ● Production Incident 🔎 Debug Guide
⚡Quick Answer
  • Allowed memory size exhausted means PHP hit its limit — bump WP_MEMORY_LIMIT to 256M
  • The host's PHP memory_limit ceiling always wins; check Site Health for the real cap
  • Audit hungry plugins with Query Monitor on staging before raising limits blindly
  • Cache pages and trim autoloaded options so each request needs less memory
  • Exhaustion at every new ceiling means a leak — stop raising and profile the code
✦ Definition~90s read
What is WordPress Fatal Error?

PHP gives every request a fixed memory allowance, controlled by the memory_limit setting. WordPress requests its own share via WP_MEMORY_LIMIT (front end) and WP_MAX_MEMORY_LIMIT (admin), defaulting to 40M and 256M-ish depending on version. When rendering a page allocates more than the allowance — loading hundreds of posts, huge meta queries, image crunching — PHP kills the request with Allowed memory size exhausted.

★
Imagine a desk where you spread out paperwork for each task.

The number in the message (134217728 bytes is 128M) tells you the ceiling that was hit.

Three forces push usage up. Plugin bloat is the biggest: each active plugin loads code and data into every request, and page builders, multilingual systems, and security scanners are famously hungry. Bloated data is next — autoloaded options and expired transients force megabytes into memory on each load.

Finally, low ceilings: budget shared plans set PHP memory_limit at 128M or even 64M, which a modern WooCommerce stack can exceed just saying hello.

Raising the limit is step one, not the whole fix. If 256M holds steady, you had a ceiling problem. If usage climbs to whatever you set — 256M exhausted, then 512M exhausted — you have a leak or bloat problem, and no number will save you. The audit steps below tell the two apart before you pay for a bigger plan you don't need.

Plain-English First

Imagine a desk where you spread out paperwork for each task. WordPress gets a desk of fixed size (the memory limit). Each plugin spreads more papers. When a page builder plus translation plus security plugins cover the desk, the next paper falls off — that's the exhausted error. You either get a bigger desk (raise the limit) or clear papers you don't need (trim plugins).

Your site dies with a chillingly specific message: Fatal error: Allowed memory size of 134217728 bytes exhausted. Sometimes it's a white screen backed by that line in the log; sometimes the message prints right on the page. Either way, WordPress is telling you it ran out of working memory halfway through building the page.

This error has a split personality. Often the fix is trivial — a limit set absurdly low for a modern site. But sometimes the limit is a smoke alarm for a real fire: a plugin leaking memory on every post, an autoloaded options table stuffed with megabytes of transients, or a hosting plan that simply can't feed your plugin stack.

This guide covers both personalities. You'll raise WP_MEMORY_LIMIT correctly, check the host ceiling that can silently override you, audit which plugins actually eat memory, and cut per-request usage with caching and autoload cleanup. You'll learn when to raise the number — and when to stop raising and start trimming. The byte figure in the error names your starting point; the steps below tell you which side of the problem you're on.

Read the Exhausted Error Like a Receipt

The message is more useful than it looks: Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes). The first number is the ceiling — 134217728 bytes equals 128M. The second is the straw that broke it, usually tiny. The ceiling tells you which limit to raise; the tiny allocation tells you the code wasn't doing anything crazy, it just ran out of room.

Check who set that ceiling. WordPress asks for WP_MEMORY_LIMIT, but PHP's memory_limit ini value is the hard cap — the lower of the two wins. If the message says 67108864 (64M), your site is running on a deeply outdated default. If it says 134217728 (128M) after you set 256M in wp-config.php, the host is overriding you.

Also note where it fires. Exhaustion on one admin import page points at that importer. Exhaustion on every front-end page points at a globally loaded plugin or autoload bloat. Exhaustion only on search or archive pages points at unbounded queries returning thousands of rows. The log line includes the file and line of the final allocation — that file is where the memory pressure peaked, though not always where it leaked. Record the ceiling figure and the firing URL together; the pair tells the next debugger whether the limit or the page changed.

📊 Production Insight
Convert the byte figure before anything else: 134217728 is 128M, 268435456 is 256M. The ceiling number tells you whether your wp-config.php raise actually took effect.
🎯 Key Takeaway
The byte figure names the effective ceiling — compare it against your wp-config.php value to spot host overrides.

Raise WP_MEMORY_LIMIT the Right Way

The standard fix is two constants in wp-config.php, placed above the stop-editing comment: WP_MEMORY_LIMIT for the front end and WP_MAX_MEMORY_LIMIT for wp-admin. 256M resolves the large majority of cases on modern stacks — builders, commerce, multilingual — without masking real leaks. Reload the failing page and confirm the error is gone under normal traffic.

Placement matters. Constants must be defined before WordPress boots, so burying them at the bottom of wp-config.php or inside a conditional that doesn't fire silently does nothing. Multisite owners note the front-end constant applies per site load while admin screens use the max constant — set both even if only the storefront errors today. After saving, verify with Site Health > Info > Server, which shows the effective WordPress memory limit. If it still shows the old number, your edit is in the wrong place or the host overrides it.

Don't escalate blindly. Jumping to 512M or 1G on shared hosting can get the account throttled, and it hides leaks that will eat any value. Raise once to 256M; if exhaustion returns at the new ceiling, switch to hunting the eater instead of feeding it. Screenshot the Site Health memory lines before and after; the pair proves the raise landed and dates the change.

wp-config.phpPHP
1
2
3
4
5
6
// Raise the WordPress memory allowance (before "stop editing" line)
define( 'WP_MEMORY_LIMIT', '256M' );
define( 'WP_MAX_MEMORY_LIMIT', '256M' );

// Verify under Tools > Site Health > Info > Server.
// If it still shows 128M, the host's PHP memory_limit is overriding you.
📊 Production Insight
One raise to 256M, then verify in Site Health. If exhaustion reappears at the new ceiling, that's a leak signal — stop raising and start auditing.
🎯 Key Takeaway
Set both memory constants to 256M above the stop-editing line, then verify the effective value.

Check the Host PHP Ceiling That Overrides You

WordPress can only spend what PHP allows. The memory_limit in php.ini (or the host's panel) caps every request, and WP_MEMORY_LIMIT values above it are silently ignored. This is the number-one reason raises mysteriously fail on shared hosting: wp-config.php says 256M while PHP enforces 128M.

Find the real value in Tools > Site Health > Info > Server, which lists both the PHP memory limit and the WordPress limit side by side. If PHP shows 128M, your options are asking the host to raise it, switching to a plan with a higher allowance, or cutting usage to fit. Some hosts let you set memory_limit via .user.ini or the panel — try memory_limit = 256M there and re-check Site Health. Note .user.ini caches for several minutes, so wait before retesting or you'll condemn a fix that hasn't loaded yet. When the panel lacks a memory control, ask support for the exact ini scope — per-domain values beat global requests.

VPS owners edit php.ini directly and restart PHP-FPM, but match the change to real RAM — promising 1G per request on a 2G server means two concurrent requests can OOM the box. On any plan, the honest fix for a stack that needs 512M per page is trimming the stack, not renting a bigger box to feed it.

BASH
1
2
3
4
5
6
7
8
9
# What does PHP itself allow? (VPS / SSH)
php -i | grep -i memory_limit

# Or create a 10-second info page, check it, then DELETE it:
# <?php phpinfo();
# Look for memory_limit in Core settings.

# Shared hosts: try .user.ini in the WordPress root
# memory_limit = 256M
📊 Production Insight
Site Health showing PHP 128M next to WordPress 256M explains every failed raise. The PHP line is the law — change it at the host level or cut usage.
🎯 Key Takeaway
PHP memory_limit caps everything — confirm it in Site Health before blaming plugins.

Audit Hungry Plugins With Query Monitor

When the ceiling is fine and memory still dies, something is eating. Query Monitor on staging shows per-page memory, slow queries, and the components behind them. Load the failing page, read the memory figure in the admin bar, then deactivate suspects one by one and re-measure. The delta per plugin is the evidence — no guessing.

Usual suspects have patterns. Page builders inflate memory on every page they touch, even via widgets. Multilingual plugins duplicate queries per language. Security scanners hook into every request. Backup and stats plugins run heavy jobs inside page loads instead of cron. Two plugins doing the same job (two sliders, two SEO packs) double the cost for zero benefit.

Judge by numbers, not reputation. A well-coded builder at 40MB is fine; a abandoned widget at 120MB is not. Snapshot the Query Monitor memory figure before and after each deactivation so deltas are comparable — eyeballing consecutive loads without notes invents patterns. Options for the eater: update it (leaks get fixed), restrict it to needed pages with a plugin organizer, replace it with a lighter alternative, or drop the feature. Record the before/after figures so the next person doesn't re-install the hog.

BASH
1
2
3
4
5
6
7
8
9
# Staging-only bisect: measure, deactivate, re-measure
wp plugin list --status=active --field=name
wp plugin deactivate suspect-slider
# reload the failing page, note Query Monitor memory
wp plugin deactivate old-stats-pack
# reload again — compare the deltas

# Back on production, remove only the proven eater
wp plugin deactivate proven-hog
💡Measure on Staging, Not Production
Deactivating plugins on a live store breaks the checkout for real customers. Clone to staging, install Query Monitor there, and bisect safely.
📊 Production Insight
Per-plugin memory deltas beat every opinion about which plugin is heavy. The one adding 100MB+ to a single load is the eater regardless of its reviews.
🎯 Key Takeaway
Measure per-plugin memory deltas on staging — replace or restrict whatever adds triple digits of megabytes.

Trim Autoloaded Options and Transients

Every WordPress request loads all autoload=yes options into memory before anything renders. Healthy sites keep this under 1MB; neglected ones carry 5–10MB of expired transients, abandoned plugin settings, and logged junk. That weight lands inside every single page load, pushing hungry pages over the edge.

Diagnose with two queries: sum the autoloaded size, then list the 20 biggest rows. Expired _transient_ rows from dead plugins are the classic find — safe to delete. Abandoned plugin settings (rows from plugins you removed years ago) are next — also deletable. Active plugin data should be set to autoload no rather than deleted.

Clean carefully. Never delete rows for active plugins or anything with _site_transient_timeout companions you don't understand. Schedule weekly deletion of expired transients with a housekeeping plugin so the table can't regrow silently between manual cleanups. Recheck the 20-biggest list monthly; new plugins add new autoload rows quietly. Take a database backup first, clean in small batches, and re-measure the autoload total after each round. Sites have dropped 8MB of autoload to under 1MB in one session — that's 7MB back on every request, often enough to end the exhaustion without touching any limit.

SQL
1
2
3
4
5
6
7
8
9
10
11
-- How heavy is the autoloaded payload on every request?
SELECT SUM(LENGTH(option_value)) AS autoload_bytes
FROM wp_options WHERE autoload = 'yes';

-- The 20 biggest rows (usual suspects for bloat)
SELECT option_name, LENGTH(option_value) AS size
FROM wp_options WHERE autoload = 'yes'
ORDER BY size DESC LIMIT 20;

-- Stop a junk row from loading on every request
UPDATE wp_options SET autoload = 'no' WHERE option_name = 'dead_plugin_cache';
📊 Production Insight
Autoload totals above 2–3MB deserve cleanup before any limit raise. Expired transients from long-deleted plugins are free megabytes.
🎯 Key Takeaway
Keep autoloaded options lean — delete dead transients and flip junk rows to autoload no.

Cut Per-Request Work With Caching and Batches

The durable fix is needing less memory per request. Full-page caching is the biggest lever: a cached page serves without booting the heavy plugin path at all, so the hungry builder code never runs for anonymous visitors. Object caching moves repeated queries out of PHP memory into Redis or Memcached. Either can halve peak usage alone.

Next, stop loading everything at once. Huge archives should paginate or lazy-load instead of querying hundreds of posts per page. Imports and image regeneration belong in small WP-CLI batches at 03:00, not in admin page loads at noon — the Black Friday incident was exactly this mistake. WP-Cron jobs should stagger so two heavy tasks never share a minute.

Re-measure after each change with the same failing page and the same tool. Object caching helps the logged-in paths page caches skip — members and carts still boot the heavy stack, so keep auditing those separately. Log peak memory per template monthly; slow growth over quarters signals a leak long before users notice. Caching first, then batching, then trimming — each step lowers the ceiling your site genuinely needs. The goal isn't the biggest limit you can set; it's a stack comfortable at 256M with headroom to spare.

📊 Production Insight
Page caching removes the hungry code path for most visitors entirely. It's the only fix that lowers memory for traffic you haven't received yet.
🎯 Key Takeaway
Cache full pages, batch heavy jobs off-peak, and paginate archives — need less instead of allowing more.
● Production incidentPOST-MORTEMseverity: high

Black Friday Import Ate 512M and Killed Checkout Twice

Symptom
At 09:12 on Black Friday the store started throwing memory-exhausted fatals on checkout and cart pages. The first crash cleared after a PHP restart at 09:25, then returned at 09:47. In total 52 minutes of broken checkout across two windows, about 610 abandoned carts, and a support queue of 90 messages. Admin product pages were also white.
Assumption
The team blamed the traffic surge and immediately raised WP_MEMORY_LIMIT from 256M to 512M, then asked the host for more memory. When the error persisted at 512M, they assumed the plan was too small and started an emergency migration to a bigger server.
Root cause
A scheduled product-sync plugin pulled all 18,000 products with their meta into a single PHP array at 09:00 to recompute sale prices — peak hour. Each product with meta cost roughly 25KB, so the import alone needed about 450MB inside a request already carrying WooCommerce and the page builder. Raising the limit just let the import eat further before dying; traffic was a bystander.
Fix
They disabled the scheduled sync, processed the price update in batches of 500 via WP-CLI at 03:00, and capped the sync to changed products only. WP_MEMORY_LIMIT stayed at 256M. A staging run with Query Monitor confirmed peak import memory dropped from 470MB to 38MB, and the rest of Black Friday ran clean.
Key lesson
  • When exhaustion survives a limit raise, stop raising and find the eater. A batch of 18,000 products in one array will defeat any ceiling you set.
  • Never schedule bulk imports during sales peaks. Heavy jobs belong at 03:00 in small batches, not at 09:00 on Black Friday in one gulp.
  • Measure per-component memory on staging with Query Monitor before big days. The 470MB import spike would have shown up in one rehearsal run.
Production debug guideFive steps — raise, verify the ceiling, find the eater, trim, cache.5 entries
Symptom · 01
Log shows Allowed memory size exhausted at a low number
→
Fix
Add define('WP_MEMORY_LIMIT', '256M'); and define('WP_MAX_MEMORY_LIMIT', '256M'); to wp-config.php before the stop-editing line, then reload. If the error disappears and stays gone under normal traffic, it was a ceiling problem and you're done — skip to the prevention steps.
Symptom · 02
Exhaustion persists after raising WP_MEMORY_LIMIT
→
Fix
Check the real ceiling in Tools > Site Health > Info > Server (PHP memory limit) or a phpinfo page. If the host sets memory_limit to 128M, WordPress can't exceed it no matter what wp-config.php says. Ask the host to raise it or move plans — config edits can't beat the PHP ini.
Symptom · 03
Need to find which plugin eats the memory
→
Fix
On staging, install Query Monitor and load the failing page. Open the admin bar's memory readout and the Queries panel. Deactivate the hungriest plugins one by one and re-measure. A plugin adding 100MB+ to a single page load is your eater — update, replace, or restrict it to the pages that need it.
Symptom · 04
Memory climbs on every page, pointing at autoloaded data
→
Fix
Run SELECT SUM(LENGTH(option_value)) FROM wp_options WHERE autoload='yes'; — if it's several megabytes, list the worst rows with SELECT option_name, LENGTH(option_value) AS size FROM wp_options WHERE autoload='yes' ORDER BY size DESC LIMIT 20;. Set junk rows (expired transients, abandoned plugin data) to autoload='no' or delete them.
Symptom · 05
Usage is legitimately high on a big catalog or builder site
→
Fix
Cut per-request work: enable full-page caching so most hits never boot PHP's heavy path, paginate or lazy-load huge archives, and move imports and image regeneration to off-peak WP-CLI batches. Re-measure after each change — caching alone often halves peak memory.
Memory Exhaustion Causes Compared
Root CauseHow to ConfirmFixPrevention
WP_MEMORY_LIMIT set too lowError ceiling is 40M/64M; raise to 256M fixes itSet WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT to 256MShip 256M in your standard wp-config.php template
Host PHP memory_limit capSite Health shows PHP limit below WordPress requestRaise via host panel/.user.ini or upgrade planCheck both limits before launching; document the cap
Hungry or leaking pluginQuery Monitor shows 100MB+ delta for one pluginUpdate, restrict, or replace the eaterStage plugin additions with memory measurements
Bloated autoloaded optionsAutoload sum is several MB; giant transient rowsDelete dead rows; flip junk to autoload noClean transients on schedule; remove plugin leftovers
⚙ Quick Reference
4 commands from this guide
FileCommand / CodePurpose
wp-config.phpdefine( 'WP_MEMORY_LIMIT', '256M' );Raise WP_MEMORY_LIMIT the Right Way
php -i | grep -i memory_limitCheck the Host PHP Ceiling That Overrides You
wp plugin list --status=active --field=nameAudit Hungry Plugins With Query Monitor
SELECT SUM(LENGTH(option_value)) AS autoload_bytesTrim Autoloaded Options and Transients

Key takeaways

1
Read the byte figure
it names the effective ceiling you actually hit.
2
Raise once to 256M and verify in Site Health; then stop raising.
3
Host PHP memory_limit always wins over wp-config.php requests.
4
Measure per-plugin memory deltas on staging to find the eater.
5
Keep autoloaded options under ~1MB by clearing dead transients.
6
Cache pages and batch heavy jobs so requests need less memory.

Common mistakes to avoid

5 patterns
×

Jumping straight to 512M or 1G

Symptom
The error returns at the new ceiling days later, and shared hosts throttle the account for overuse — the leak is still there, just better fed.
Fix
Raise once to 256M. If exhaustion recurs at 256M, audit plugins and autoload data instead of raising again.
×

Editing memory constants in the wrong place

Symptom
Site Health still shows the old limit after your edit, so the white screen persists and you conclude the fix doesn't work.
Fix
Place both defines above the stop-editing line in wp-config.php, then verify the effective value in Site Health before retesting.
×

Deactivating plugins on the live store to test

Symptom
Customers hit a broken checkout or missing features during your test, and some page caches keep serving the broken layout afterward.
Fix
Bisect on a staging clone with Query Monitor. Change production only to remove the proven eater.
×

Deleting wp_options rows blindly

Symptom
The site loses settings or a plugin breaks because you deleted live configuration alongside the junk transients.
Fix
Back up first, delete only expired transients and rows from long-removed plugins, and flip uncertain rows to autoload no instead of deleting.
×

Running bulk imports inside page loads at peak hours

Symptom
Imports exhaust memory and take checkout down with them, exactly when every minute of downtime costs the most.
Fix
Run imports as small WP-CLI batches off-peak, limited to changed records, with memory measured on staging first.
INTERVIEW PREP · PRACTICE MODE

Interview Questions on This Topic

Q01JUNIOR
What does Allowed memory size exhausted mean?
Q02JUNIOR
How do you raise the WordPress memory limit?
Q03SENIOR
Why would raising WP_MEMORY_LIMIT have no effect?
Q04SENIOR
How do you find which plugin uses the most memory?
Q05SENIOR
Exhaustion returns at every new ceiling you set. What's your diagnosis?
Q01 of 05JUNIOR

What does Allowed memory size exhausted mean?

ANSWER
PHP killed the request because rendering exceeded the memory allowance. The byte figure names the effective ceiling. Causes split into low ceilings (WP_MEMORY_LIMIT or host memory_limit too small) and high consumption (hungry plugins, autoload bloat, bulk operations in one request).
FAQ · 6 QUESTIONS

Frequently Asked Questions

01
Is 256M safe for shared hosting?
02
What's the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?
03
Can too many transients really crash a site?
04
Will more plugins always mean more memory?
05
Does object caching help memory exhaustion?
06
Should I just upgrade my hosting plan?
N
Naren Founder & Principal Engineer

20+ years shipping production backend systems. Everything here is grounded in real deployments.

Follow
✓ Verified
production tested
September 27, 2026
last updated
2,085
articles · all by Naren
🔥

That's WordPress. Mark it forged?

5 min read · try the examples if you haven't

←
Previous
WordPress White Screen of Death — Isolate the Plugin
3 / 5 · WordPress
Next
WordPress Too Many Redirects After URL Change
→