Summarize this article with:
Your site crashes. The admin dashboard won’t load. A cryptic message about “bytes exhausted” appears out of nowhere.
The WordPress Memory Exhausted Error stops PHP scripts dead when they exceed your server’s allocated memory limit.
It happens during plugin updates, media uploads, or random page loads. Frustrating and unpredictable.
The fix takes under 15 minutes once you know where to look.
This guide walks you through checking your current PHP memory limit, editing wp-config.php and .htaccess files, identifying resource-hungry plugins, and knowing when shared hosting no longer fits your needs.
Five methods. Clear steps. No guesswork.
What Is the WordPress Memory Exhausted Error?
The WordPress Memory Exhausted Error occurs when PHP scripts exceed the allocated server memory limit during execution.
You’ll see this message: “Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes).”
WordPress runs on PHP, and PHP needs RAM to process requests, run plugins, and load themes.
When your site demands more memory than available, PHP stops working entirely.
Have you seen the latest WordPress statistics?
Discover the latest WordPress statistics: market share, security trends, performance data, and revenue insights that shape the web.
Check Them Out →Newer WordPress versions hide this behind a generic message: there has been a critical error on this website.
Common triggers include:
- Resource-intensive plugins (page builders, WooCommerce, security tools)
- Large image uploads without optimization
- Theme conflicts or poorly coded themes
- Traffic spikes on shared hosting plans
- Memory leaks from outdated PHP versions
This guide covers 5 methods to fix the error, requiring 10-15 minutes and basic file editing knowledge.
Prerequisites
Before editing any WordPress core files, gather these requirements:
- WordPress version: 6.0 or later
- Access method: FTP client (FileZilla) or cPanel File Manager
- Text editor: Notepad++, VS Code, or similar
- Skill level: Basic file editing
- Time needed: 10-15 minutes
- Backup: Complete site backup before making changes
You’ll need access to your site’s root directory (publichtml folder).
Know where php.ini is located in WordPress if your hosting requires that method.
Some hosts restrict file editing on shared plans, so check with your provider first.
Step 1: How Do You Check Your Current PHP Memory Limit?
Open your WordPress admin dashboard and go to Tools > Site Health > Info > Server.
Look for the “PHP memory limit” value, which shows your current allocation in megabytes.
Most sites need at least 128M. If yours shows 32M or 64M, that’s likely causing the exhausted memory error.
What the Numbers Mean
M is WordPress default. 64M works for small sites with minimal plugins.
M handles most standard WordPress installations. 256M suits WooCommerce stores or sites with page builders like Elementor or Divi.
M is typically the maximum shared hosting allows.
Alternative Check Method
Can’t access the dashboard? Enable WordPress to show PHP errors or check your WordPress error log for the exact byte limit.
The error message itself tells you the current limit: “Allowed memory size of 67108864 bytes” equals 64M.
Step 2: How Do You Increase Memory Limit in wp-config.php?

Connect to your server via FTP or open cPanel File Manager.
Navigate to publichtml and locate wp-config.php.
Download a backup copy before editing.
Adding the Memory Code
Open wp-config.php and find this line:
/ That's all, stop editing! Happy publishing. /
Add this code directly ABOVE that line:
define('WPMEMORYLIMIT', '256M');
For backend operations like plugin updates, add:
define('WPMAXMEMORYLIMIT', '512M');
Save and Test
Save the file and upload it back to your server, overwriting the original.
Clear your browser cache and reload your site.
Return to Site Health to confirm the new memorylimit value appears.
If unchanged, your hosting provider may enforce a lower cap. Contact their support team.
Step 3: How Do You Modify the .htaccess File for More Memory?
This method works only on Apache servers with modphp enabled. NGINX servers won’t recognize .htaccess directives.
Locate .htaccess in your publichtml folder. Can’t see it? Enable “Show Hidden Files” in File Manager settings.
Adding Memory Directives
Open .htaccess and find this line:
# END WordPress
Add this code BEFORE that line:
“ phpvalue memorylimit 256M phpvalue maxexecutiontime 300 `
The maxexecutiontime prevents timeout errors during memory-heavy operations.
When This Method Fails
Getting a 500 internal server error after saving? Your server doesn’t support phpvalue in .htaccess.
Remove the lines you added and try the wp-config.php method instead.
PHP-FPM configurations require php.ini edits or hosting panel adjustments, not .htaccess modifications.
Step 4: How Do You Edit php.ini to Raise Memory Allocation?

The php.ini file controls PHP configuration at the server level. This method works on VPS, dedicated servers, and some managed hosting plans.
Shared hosting rarely allows php.ini access.
Locating the File
Check your root directory (publichtml) first. If php.ini doesn’t exist, look in the server’s PHP configuration folder or create a new file named php.ini.
Some hosts use php5.ini or .user.ini instead.
Editing Memory Values
Open php.ini and find this line:
memorylimit = 64M
Change it to:
memorylimit = 256M
Save the file and restart your web server if you have SSH access. Otherwise, wait 5-10 minutes for changes to take effect.
Verify through Site Health that the new PHP memory limit appears.
Step 5: How Do You Identify Plugins Causing High Memory Usage?
Plugin conflicts drain server resources fast. One poorly coded plugin can consume 50MB+ per page load.
Page builders, security plugins, and WooCommerce extensions are common culprits.
The Deactivation Test
Go to Plugins > Installed Plugins in your WordPress admin dashboard.
Select all plugins and choose “Deactivate” from the bulk actions dropdown.
If the memory exhausted error disappears, a plugin caused it.
Finding the Culprit
Reactivate plugins one at a time, checking your site after each activation.
When the error returns, you’ve found the problem plugin. Either replace it, contact the developer, or check for available updates.
Query Monitor plugin shows real-time memory consumption per component if you need detailed diagnostics.
Step 6: How Do You Check if Your Theme Consumes Too Much Memory?
Themes with heavy scripts, large image assets, and complex layouts require significant memory allocation.
A bloated theme can trigger the WordPress fatal error: out of memory even with adequate server resources.
Switch to Default Theme
Navigate to Appearance > Themes and activate Twenty Twenty-Five or Twenty Twenty-Four.
These starter themes use minimal resources. If the error stops, your theme needs optimization or replacement.
Theme Troubleshooting Steps
Check for WordPress theme errors in your error log before switching back.
Update your theme to the latest version, disable theme-specific features one by one, and contact the theme developer if problems persist.
Step 7: How Do You Update PHP Version to Fix Memory Issues?
Older PHP versions (5.6, 7.0, 7.1) handle memory inefficiently and contain security vulnerabilities.
PHP 8.2 and 8.3 process requests 30-40% faster with lower memory consumption.
Updating in cPanel
Go to cPanel > Software > MultiPHP Manager or Select PHP Version.
Choose your domain and select PHP 8.2 or 8.3 from the dropdown. Click Apply.
After Updating
Test your site immediately. Some older plugins cause syntax errors on newer PHP versions.
If you see the WordPress white screen of death, revert to your previous PHP version and update incompatible plugins first.
What Should You Do if Shared Hosting Limits Your Memory?
Shared hosting splits server RAM among hundreds of users. Your host may cap memory at 128M or 256M regardless of configuration changes.
Contact Your Provider
Submit a support ticket requesting a memory limit increase. Some hosts accommodate this on higher-tier shared plans.
Ask specifically about PHP memory limits, not disk space or bandwidth.
Upgrade Options
When shared hosting no longer fits your needs:
- Managed WordPress hosting: SiteGround, WP Engine, Cloudways offer 512M-1GB limits
- VPS hosting: Full control over php.ini and server configuration
- Dedicated server: Maximum resources, maximum cost
Growing traffic, WooCommerce stores, and membership sites typically require VPS or managed hosting.
Verification
After applying any fix, confirm the changes worked.
Check Site Health
Return to Tools > Site Health > Info > Server and verify the new memorylimit value displays correctly.
If unchanged, your hosting provider’s cap overrides your configuration.
Test Previous Actions
Repeat the action that triggered the original error: upload large media files, activate the plugin, or run the database query.
No error message means success. If an error occurred in the upload or elsewhere, increase the memory value further.
Troubleshooting
Memory Limit Shows Old Value After wp-config.php Edit
Cause: Code placed in wrong location or hosting enforces lower cap.
Fix: Ensure the define() line appears BEFORE “That’s all, stop editing!” and clear all caches. Contact hosting if the problem continues.
Error Returns After Short Period
Cause: Memory leak in plugin or theme code.
Fix: Install Query Monitor to track memory consumption, identify the leaking component, and replace or update it.
.htaccess Changes Have No Effect
Cause: Server runs NGINX or PHP-FPM instead of Apache with modphp.
Fix: Use wp-config.php or php.ini methods instead. Check with your host about their server stack.
Error Occurs Only in Admin Dashboard
Cause: WPMAXMEMORYLIMIT not set for WordPress fatal errors in admin areas.
Fix: Add define(‘WPMAXMEMORYLIMIT’, ‘512M’); to wp-config.php alongside the regular memory limit.
Database Connection Errors After Memory Fix
Cause: Unrelated issue or corrupted configuration file.
Fix: Restore your wp-config.php backup and check for error establishing a database connection separately. Verify MySQL credentials remain correct.
FAQ on WordPress Memory Exhausted Error
What causes the WordPress memory exhausted error?
PHP scripts exceed the server’s allocated memory limit. Common triggers include resource-intensive plugins, large media uploads, theme conflicts, and traffic spikes on shared hosting plans.
Outdated PHP versions also consume memory inefficiently.
What is the default WordPress memory limit?
WordPress sets the default PHP memory limit to 32MB. When this limit is reached, WordPress automatically increases it to 40MB for single sites and 64MB for multisite networks.
How much memory does WordPress need?
Basic sites run fine on 128MB. WooCommerce stores and sites using page builders like Elementor or Divi need 256MB minimum.
Heavy traffic sites benefit from 512MB.
Where do I add the WPMEMORYLIMIT code?
Add define(‘WPMEMORYLIMIT’, ‘256M’); to your wp-config.php file. Place it before the line that says "That's all, stop editing!" Save and upload the file.
Why doesn’t my memory limit change after editing wp-config.php?
Your hosting provider enforces a lower cap. Shared hosting plans often restrict memory regardless of configuration changes.
Contact your host’s support team to request an increase.
Can plugins cause memory exhausted errors?
Yes. Security plugins, page builders, and WooCommerce extensions consume significant memory. Poorly coded plugins create memory leaks that compound over time.
Query Monitor helps identify high-consumption plugins.
Does updating PHP version help with memory issues?
PHP 8.2 and 8.3 process requests more efficiently than older versions. Upgrading from PHP 7.x reduces memory consumption by 30-40% and improves overall site performance.
What is the difference between WPMEMORYLIMIT and WPMAXMEMORYLIMIT?
WPMEMORYLIMIT controls memory for frontend operations. WPMAXMEMORYLIMIT sets the limit for admin dashboard tasks like plugin updates and media uploads.
Will increasing memory limit slow down my site?
No. Allocating more memory prevents crashes without affecting speed. Your site only uses what it needs.
Unused allocated memory remains available for other server processes.
When should I upgrade from shared hosting?
Upgrade when memory errors persist despite optimization, your site runs WooCommerce with many products, or traffic exceeds 50,000 monthly visitors. VPS and managed WordPress hosting offer higher memory allocation.
Conclusion
The WordPress Memory Exhausted Error looks scary but rarely requires advanced technical skills to fix.
Start with Site Health to check your current memorylimit value. Edit wp-config.php or php.ini to increase allocation. Test your plugins and themes for memory leaks.
Most sites run smoothly on 256MB. WooCommerce stores may need 512MB.
If shared hosting caps your resources, upgrading to VPS or managed WordPress hosting solves the problem permanently.
Keep PHP updated to version 8.2 or 8.3 for better memory efficiency. Monitor your server resources regularly with Query Monitor.
One configuration change today prevents crashes tomorrow. Back up your files, make the edit, and move on.
