Memory Exhausted Error is a PHP fatal error that occurs when a WordPress site attempts to use more memory than its server configuration allows. The error message typically reads something like: “Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate X bytes).” When this error fires, PHP stops execution entirely — which means the affected page either shows nothing, a blank white screen, or the raw error message, depending on how debug mode is configured.
PHP, the programming language that powers WordPress, allocates a defined amount of memory to each running process. When a WordPress page load — or a specific action like installing a plugin, importing content, or running a background task — requires more memory than that limit allows, PHP throws this error rather than continuing. It’s one of the more common WordPress errors, particularly on sites running many plugins, processing large data sets, or hosted on plans with low PHP memory limits. The good news is it’s almost always fixable.
How the Memory Limit Works in WordPress
Several configuration layers control the PHP memory limit available to WordPress:
- Server-level
php.ini— The hosting server’s base PHP configuration sets the master memory limit. Typically 128MB or 256MB on shared hosting, higher on managed or dedicated environments. wp-config.php— WordPress can request a specific memory limit by definingWP_MEMORY_LIMITin wp-config.php. This is a request, not an override — the server’s hard limit still applies.- WordPress default — Without explicit configuration, WordPress requests at least 40MB of PHP memory. It will attempt to request 256MB if available.
- Admin limit — WordPress also defines
WP_MAX_MEMORY_LIMITfor admin-side tasks, which often require more memory than front-end page loads.
The typical fix involves raising one or more of these limits. The appropriate path depends on which limit is actually enforcing the constraint.
[Image: Diagram showing the three-layer memory limit hierarchy: server php.ini → wp-config.php WP_MEMORY_LIMIT → WordPress default, with arrows showing which setting takes precedence]
Purpose & Benefits of Understanding This Error
1. Faster, More Accurate Troubleshooting
The Memory Exhausted Error is precise in what it tells you: PHP ran out of memory executing something specific. Understanding the error structure — the byte count, the context in which it fires — helps narrow down the cause. Is it a specific plugin activation? A particular admin action? An image import? Knowing what to look for gets you to a solution faster than generic WordPress troubleshooting. Checking wp-config.php and enabling WP_DEBUG mode are the right first steps.
2. Distinguishing a Configuration Problem from a Performance Problem
A Memory Exhausted Error sometimes reveals that the memory limit simply needs to be raised. But it can also reveal that a plugin has a memory leak, or that a site is trying to do something fundamentally inefficient — like loading thousands of database records into memory at once. Understanding the error helps you determine whether you need to raise a limit, fix a plugin, optimize code, or upgrade your hosting plan.
3. Preventing the White Screen of Death
Unhandled PHP fatal errors — including memory exhaustion — are the most common cause of the White Screen of Death (WSOD). A blank white page with no visible error is often a memory limit error that PHP couldn’t display because it ran out of memory before the output could render. Proactively setting an appropriate memory limit and enabling error logging prevents silent failures that are hard to diagnose.
Examples
1. Plugin Installation Triggers the Error
A site owner installs a large plugin — a page builder, an e-commerce extension, or a data import tool. During activation, the plugin loads a significant amount of code and data. The PHP process hits the memory limit mid-activation, throws a fatal error, and the plugin fails to activate properly. Adding define('WP_MEMORY_LIMIT', '256M'); to wp-config.php before retrying the activation resolves it — assuming the server allows that limit.
2. Admin Page Loads Cause Errors on a High-Volume Site
A site with thousands of posts and multiple active plugins starts showing memory errors only in the WordPress admin — specifically on the Posts, WooCommerce Orders, or Plugins pages. These admin pages load more data simultaneously than front-end pages. WordPress’s WP_MAX_MEMORY_LIMIT constant, also set in wp-config.php, controls the admin-side limit separately from front-end limit. Raising it from the default resolves the issue.
3. Image Processing Exhausts Available Memory
A WooCommerce store imports a large batch of product images. WordPress attempts to generate thumbnails and resized variants for each image simultaneously. The memory required to load, process, and save dozens of image size variants exceeds the limit. The fix here involves both increasing the memory limit and potentially processing imports in smaller batches — addressing both the immediate error and the underlying inefficiency.
Common Mistakes to Avoid
- Increasing the memory limit without investigating the cause — Raising
WP_MEMORY_LIMITto 512MB or higher to silence the error without understanding why is a short-term fix. If a plugin has a memory leak, you’re just masking it. Always check whether the memory usage is reasonable for what the site is doing. - Setting a limit in wp-config.php that the server doesn’t allow — WordPress can only request up to the server’s hard limit. If you add
WP_MEMORY_LIMIT = '512M'but your host caps PHP at 256MB, the request is silently ignored. Contact your host to confirm the actual server limit. - Ignoring errors until the site breaks visibly — Memory errors often start as sporadic issues during admin tasks before they surface as visible front-end errors. Enabling WP_DEBUG logging catches these before they become critical.
- Assuming more memory always means better performance — PHP memory and site speed are different things. Raising memory limits doesn’t make a slow site faster. It only prevents crashes when processes legitimately need more memory than the current limit allows.
Best Practices
1. Set a Reasonable Memory Limit in wp-config.php
For most WordPress sites, adding define('WP_MEMORY_LIMIT', '256M'); to wp-config.php before the line /* That's all, stop editing! */ is a sensible baseline. For busy sites running WooCommerce, page builders, or complex membership plugins, 256MB is a more appropriate starting point than WordPress’s default. Pair this with define('WP_MAX_MEMORY_LIMIT', '512M'); for admin tasks on resource-intensive sites.
2. Identify and Address Inefficient Plugins
If a specific plugin repeatedly triggers memory errors, investigate whether the plugin has known memory issues and whether updates address them. Test by temporarily deactivating suspected plugins to confirm which one is responsible. Some plugins load entire datasets into memory when only a subset is needed — a sign of poor development practices. Choosing well-maintained plugins with active support reduces this risk.
3. Use WP_DEBUG Logging to Catch Errors Early
Rather than waiting for a White Screen of Death, enable debug mode with logging to a file rather than displaying errors publicly. This captures PHP errors including memory exhaustion in a log file you can review at any time. Set define('WP_DEBUG', true);, define('WP_DEBUG_LOG', true);, and define('WP_DEBUG_DISPLAY', false); in wp-config.php on non-production environments, and review the debug log regularly on production.
Frequently Asked Questions
What does the memory size number in the error mean?
The byte count shows how much memory PHP was allowed. 134217728 bytes = 128MB. 268435456 bytes = 256MB. The error also shows how much memory the process was trying to allocate when it hit the limit. This helps you gauge whether you’re slightly over the limit (suggesting a small increase will fix it) or massively over it (suggesting something is consuming memory unexpectedly).
How do I increase the PHP memory limit in WordPress?
The most common method is adding define('WP_MEMORY_LIMIT', '256M'); to your wp-config.php file before the “stop editing” comment line. Alternatively, you can add php_value memory_limit 256M to your .htaccess file (Apache only) or ask your hosting provider to increase the server-level PHP memory limit. The method that works depends on your hosting environment.
Does this error affect site visitors?
If it occurs on a front-end page, yes. Visitors will see either a blank white page or the raw error message (if debug display is on). Memory errors on front-end pages are less common than admin-side errors — they typically occur during complex operations like checkout processing or large content loads. Admin-side memory errors only affect logged-in users in the backend.
Will upgrading my hosting plan fix this?
Often, yes — if the error is caused by a legitimate need for more memory that your current plan doesn’t allow. Higher-tier hosting plans typically allow higher PHP memory limits. However, if the cause is a buggy or inefficient plugin, more memory just delays the problem. Investigate the cause before assuming a hosting upgrade is the solution.
Can too many plugins cause memory exhaustion?
Yes. Each plugin loads additional PHP code, data, and potentially its own database queries into memory. A site running 40 or 50 plugins — especially poorly coded ones — can see memory consumption that a leaner site of comparable content never experiences. Auditing and deactivating plugins that aren’t actively needed is good site hygiene regardless of whether you’re seeing memory errors.
Related Glossary Terms
- wp-config.php
- White Screen of Death (WSOD)
- Debug Mode (WP_DEBUG)
- PHP
- Shared Hosting
- Database Optimization
How CyberOptik Can Help
Memory exhaustion errors are often symptomatic of deeper configuration or plugin issues, not just a number that needs to be raised. We handle WordPress troubleshooting for clients regularly — from diagnosing the specific cause of recurring errors to recommending appropriate hosting configurations that prevent them. Get in touch to discuss your project or learn about our WordPress support services.


