WordPress

Fatal error: allowed memory size exhausted in WordPress — the real fix, not just increasing the limit

Raising the PHP memory limit makes the error go away temporarily and hides the actual problem, which is usually one specific plugin or a runaway loop consuming far more memory than it should. Here is how to find and fix the real cause.

V Vinod Kulkarni
20 August 2026 · 8 min read
Fatal error: allowed memory size exhausted in WordPress — the real fix, not just increasing the limit

Fatal error: allowed memory size exhausted in WordPress — the real fix, not just increasing the limit

TL;DR: "Allowed memory size exhausted" means a single PHP request tried to use more memory than the configured memory_limit allows, and while raising that limit is a legitimate short-term fix to restore access to your site, it does not address why the request needed that much memory in the first place. In the large majority of cases the actual cause is one specific plugin, a poorly optimized image processing operation, an inefficient database query pulling far more data than needed, or a genuine memory leak in a plugin's code, and finding that specific cause is the difference between a real fix and a limit you will keep raising indefinitely.

What the error actually means

PHP's memory_limit setting caps how much memory a single script execution is allowed to consume, a safety mechanism preventing one runaway or inefficient script from consuming all available server memory and affecting every other site or process on the same server. When a WordPress request, loading a page, running a scheduled task, processing an admin action, exceeds that cap, PHP terminates the script immediately and throws this fatal error rather than letting it continue consuming memory indefinitely.

The error message itself tells you the limit was hit; it does not tell you why that specific request needed so much memory, which is the actual diagnostic question worth answering rather than treating the limit itself as the problem.

Step 1: raise the limit to regain access

If the error is currently blocking you from accessing your site or admin area at all, raising the limit is the correct immediate step to restore access, since you cannot diagnose further while locked out entirely. This is typically done by adding a line to wp-config.php (define('WP_MEMORY_LIMIT', '256M'); for the frontend, and define('WP_MAX_MEMORY_LIMIT', '256M'); specifically for the admin area, which often needs more headroom than the frontend), or, if you have server access, adjusting PHP's own memory_limit directive directly in php.ini or via your hosting control panel.

This restores functionality but should be treated as a temporary measure while you investigate the actual cause, not as the final fix, for the reasons covered below.

Step 2: find what is actually consuming the memory

With access restored, the next step is identifying what specifically is driving memory usage this high, since a well-configured WordPress site with a reasonable plugin count should not be anywhere close to typical default limits during normal operation.

Enable WordPress debug logging by setting WP_DEBUG and WP_DEBUG_LOG to true in wp-config.php, then reproduce the error (visit the page or trigger the action that caused it) and check wp-content/debug.log for the specific file and line number where the fatal error occurred. This often points directly at a specific plugin's file, which is the single most useful piece of information for narrowing down the cause.

Deactivate plugins one at a time (or in batches, then narrowing) and retest, particularly if the error occurs on a specific page or action rather than site-wide, since this isolates whether a specific plugin is the trigger versus a more general, cumulative memory pressure from many plugins together.

Check whether the error correlates with a specific action, bulk image upload or processing, a large data import or export, a report or analytics dashboard loading, generating a PDF, or a specific admin page, since memory-intensive operations are often concentrated in identifiable, specific features rather than spread evenly across everything the site does.

Common real causes

Image processing plugins working with large source images. Generating multiple thumbnail sizes from a very large uploaded image (a 20MB+ photo straight from a modern camera or phone, for example) can consume substantial memory during the resizing operation itself, and this scales with image dimensions, not just file size in a simple linear way. Reducing maximum upload dimensions or pre-compressing images before upload directly reduces this specific memory demand.

Inefficient database queries pulling excessive data. A plugin (or custom theme code) that queries far more rows or columns than a given page actually needs, common with poorly optimized "related posts" or search functionality on a site with a large content library, can consume memory proportional to the unnecessarily large result set being loaded into PHP's memory at once.

A genuine memory leak in a plugin. Less common but real: some plugin code fails to release memory properly during a long-running process (a bulk operation, a scheduled task looping over many items), causing memory usage to climb progressively rather than staying flat, eventually exceeding the limit on operations that would have been fine at a smaller scale.

Plugin conflicts causing redundant processing. Two plugins performing overlapping work (two SEO plugins both processing the same content analysis, for example) can double memory demand for functionality that should only be running once, a cause specific to sites that have accumulated plugins over time without periodically auditing for redundancy.

WooCommerce-specific causes on stores with large catalogs. Product import/export operations, especially with many product variations and images, and certain report generation features, are disproportionately memory-intensive compared to typical WordPress operations, and are a common source of this error specifically on ecommerce sites.

Bar chart showing common causes of PHP memory exhaustion on WordPress by relative frequency: image processing on oversized uploads, inefficient plugin database queries, plugin memory leaks during bulk operations, redundant plugin conflicts, WooCommerce bulk import/export operations

Why "just raise the limit" eventually stops working

Raising the limit without finding the actual cause treats the symptom, and the underlying inefficiency, an oversized image being processed inefficiently, a query pulling unnecessary data, a memory leak accumulating over a long operation, does not go away just because it now has more room to run within before hitting a wall. As content grows (more images, more products, more posts), the same inefficient operation naturally needs more memory over time even with no code changes, meaning a limit that was "enough" today can become insufficient again in months, and you are back to raising it again, an escalating pattern rather than a resolved problem.

Beyond the recurring nature of the issue, an operation genuinely consuming excessive memory is usually also slow, since memory allocation, particularly for large datasets or images, has a real performance cost; fixing the actual cause typically improves page speed and server resource efficiency broadly, not just resolves this specific error.

A diagnostic table

Symptom pattern Likely cause What to check
Error only during image upload Oversized source images Max upload dimensions, image compression
Error only on a specific admin report/page Inefficient query on that specific feature Debug log file/line, that plugin's query code
Error grows worse over a long-running bulk task Memory leak during the operation That specific bulk feature (import/export)
Error appears site-wide with no clear pattern Cumulative load from many plugins, or a conflict Plugin-by-plugin deactivation testing
WooCommerce-specific, during import/export Catalog operation scale Batch size settings, if the plugin offers them

When raising the limit is the legitimate long-term answer

It is worth being fair to the "just raise the limit" approach in the cases where it genuinely is the correct long-term fix rather than a band-aid: a site that has grown substantially (much larger content library, higher traffic, more legitimate functionality) may simply need more memory headroom than a smaller site's typical default, in the same way a growing business needs a bigger office, not because anything is inefficient, but because the actual scale of legitimate work has increased. The distinction is whether the memory demand is proportional to genuinely necessary work (a large, well-optimized product catalog needing more memory for legitimate bulk operations) versus disproportionate to the task (a single small page taking an unreasonable amount of memory to render). The diagnostic steps above are what tell you which situation you are actually in.

FAQs

What is a reasonable memory_limit for a typical WordPress site?

There is no single correct number, but 256M is a commonly cited comfortable baseline for a standard WordPress site with a normal plugin count; a WooCommerce store or a site with heavier processing needs (image-heavy, many plugins) often needs more, while a very simple site can run fine on less. The right number for your specific site is best determined by what genuinely necessary operations require, not by picking an arbitrary large number preemptively.

Can shared hosting limit how high I can raise memory_limit?

Yes, shared hosting environments often cap the maximum memory_limit a single account can request, specifically because one account raising its limit very high on shared infrastructure would affect other tenants; if you consistently need more memory than your host allows, that is a genuine signal to consider a VPS or dedicated resources rather than continuing to fight the limit on a plan that structurally cannot exceed it.

Does WP_MAX_MEMORY_LIMIT need to be different from WP_MEMORY_LIMIT?

Yes, typically the admin area (WP_MAX_MEMORY_LIMIT) genuinely needs more headroom than the public-facing frontend (WP_MEMORY_LIMIT), since admin operations like plugin updates, media processing, and dashboard widgets tend to be more memory-intensive than serving a typical page to a visitor.

How do I read the debug.log file if I'm not comfortable with code?

The relevant line typically states the error along with a file path and line number pointing at the specific plugin or theme file involved; even without reading the surrounding code, the file path alone (often containing the plugin's folder name) usually tells you which plugin to investigate first, which is often enough to act on without needing to understand the code itself.

Is this error the same as a website "crashing"?

It produces a similar visible symptom (the page fails to load, showing an error instead), but it is a specific, identifiable PHP fatal error with a clear cause (memory limit exceeded) rather than a general crash, which is useful because it means the fix is targeted rather than requiring broad troubleshooting of an undefined failure.

Will upgrading my hosting plan fix this automatically?

A higher-tier plan often comes with a higher default or maximum allowable memory_limit, which can resolve the immediate symptom, but if the underlying cause is a genuinely inefficient plugin or oversized images, the same inefficiency persists and can eventually exceed even a higher limit as your site continues to grow, making it worth addressing the root cause regardless of whether you also upgrade.

Can a theme, not just a plugin, cause this error?

Yes, a poorly coded theme, particularly one loading many features, sliders, page builders, demo content processing, directly in its own code rather than through optimized plugins, can be just as memory-intensive as a plugin; the same debug log and elimination-testing approach applies to isolating a theme-based cause.

Conclusion

Raising the PHP memory limit is a legitimate and often necessary first step to restore access when this error blocks your site, but treating it as the complete fix misses that the error is telling you something specific consumed more memory than expected, and that something is usually identifiable and fixable rather than an inherent, unavoidable cost of running WordPress.

Enable debug logging, reproduce the error, and check what file and operation the log points to before assuming a higher limit is the end of the story. In the majority of cases, the actual cause, an oversized image, an inefficient query, a specific plugin's bulk operation, is addressable directly, and fixing it tends to improve overall site performance well beyond just resolving this one error.

HostCloud's hosting plans include generous default memory allocations sized for real WordPress workloads, and our support team can help trace a specific memory exhaustion error back to its actual cause rather than just raising the ceiling. Plans start at ₹99 a month at https://hostcloud.in.

Related posts