Memory Exhausted Error occurs when a script tries to use more memory than the server allows. When that happens, PHP stops execution to protect the server from running out of resources.
The error is common in WordPress and other PHP applications. It usually appears after installing a heavy plugin, running a complex import, processing large images, or during a traffic spike.
Quick Fix
- Increase the PHP memory limit.
- Disable recently installed plugins.
- Switch temporarily to a default theme.
- Check server logs for the script that failed.
- Clear cache and restart PHP if you have access.
- Upgrade hosting resources if the limit is hit constantly.
In most cases, raising the memory limit or disabling one problematic plugin fixes it quickly.
What Memory Exhausted Error Actually Means
PHP runs each script with a hard memory limit. That limit is how much memory one script may allocate while it runs.
When the script exceeds the limit, PHP stops and returns an error such as:
Allowed memory size of 134217728 bytes exhausted
This protects the server from one process taking everything. The message looks technical, but the cause is usually simple: a plugin, theme, or script needs more memory than the current limit allows.
Common Causes of Memory Exhausted Error
Low PHP Memory Limit
Many hosts set a conservative limit such as 128 MB. Modern WordPress sites with page builders, security plugins, and WooCommerce often need more.
Resource-Heavy Plugins
Backup tools, page builders, analytics plugins, and import tools often perform large in-memory operations and are frequent causes.
Inefficient Application Code
Poorly optimized code can load entire datasets or create unnecessary objects instead of processing data in smaller chunks.
Large File Processing
Image resizing, media uploads, and large database imports need extra memory. A single huge image can trigger the error during upload.
High Server Load
During traffic spikes, several scripts can run at once and increase memory pressure even if each one looks reasonable alone.
How to Fix Memory Exhausted Error
Step 1 — Increase the WordPress Memory Limit
This is the most common fix. Add this line to wp-config.php above the “That’s all, stop editing” comment:
define('WP_MEMORY_LIMIT', '256M');
This raises the memory available to WordPress. If the host enforces a lower hard limit, this line alone will not override it.
Step 2 — Increase PHP Memory in php.ini
If you have server access, raise the PHP limit directly:
memory_limit = 256M
Restart PHP or the web server after the change. On shared hosting this is often controlled by the plan, so you may need support to raise it.
Step 3 — Disable Problematic Plugins
If the error started after a new plugin, deactivate it. If the dashboard is inaccessible, rename the plugins folder via FTP or File Manager:
/wp-content/plugins/
Renaming it to something like plugins-old disables every plugin. Reactivate them one by one until the error returns.
Step 4 — Switch to a Default Theme
Some themes load heavy builders or scripts. Switch temporarily to a default theme such as Twenty Twenty-Four to see whether the theme is the cause.
Step 5 — Optimize Media and Imports
Resize images before upload and avoid extremely large imports. Processing a multi-megabyte image or a huge CSV in one request can exhaust memory even with a higher limit.
Advanced Troubleshooting
Check Server Error Logs
The log usually names the file that exceeded the limit. That points straight to a plugin, theme, or custom script.
Profile Plugin Resource Usage
Query Monitor or a similar plugin can show which plugins use the most memory on a request. Use it carefully on a staging site if production is already tight.
Inspect Database Queries
Inefficient queries can load large result sets into memory. Look for unbounded queries and plugins that fetch everything at once.
Upgrade Hosting Resources
If exhaustion happens often even after cleanup, the server may simply lack capacity. A plan with a higher PHP memory limit and more RAM is the practical fix.
Does Memory Exhausted Error Affect SEO?
Yes, if pages fail to load. Search engines cannot crawl them. Short outages rarely hurt rankings. Repeated failures can reduce indexing and visibility until the site is stable again.
Prevention Best Practices
- Prefer lightweight plugins and remove unused ones.
- Delete unused themes.
- Monitor PHP memory and server load.
- Resize images before upload.
- Keep WordPress, themes, and plugins updated.
- Avoid running heavy backups and imports during peak traffic.
When to Contact Support
Contact your host if you cannot raise the memory limit, the server hits the limit repeatedly, or the error continues after plugins are disabled. Support can confirm the real PHP limit and whether the plan needs more resources.
FAQ
What causes Memory Exhausted Error?
A PHP script exceeded the allowed memory limit.
Is this error common in WordPress?
Yes. It often appears when plugins or themes use more memory than the host allows.
Does increasing memory always solve the problem?
It fixes many cases. Inefficient plugins or scripts can still exhaust a higher limit, so cleanup still matters.
Can large images trigger this error?
Yes. Image processing during upload or regeneration can need a large amount of memory.
Is upgrading hosting necessary?
If exhaustion happens frequently after optimization, a plan with a higher PHP memory limit is usually required.
Summary
Memory Exhausted Error occurs when a script tries to allocate more memory than the server allows.
The usual causes are a low PHP limit, a heavy plugin, inefficient code, or large file processing. Raise the limit, disable the offending plugin or theme, and optimize media. If it keeps returning, the host needs more resources.
Related WordPress Errors
If you’re troubleshooting WordPress issues, these guides may help: