WordPress Memory Limit: How to Fix Memory Exhausted Errors and Configure PHP Memory
WordPress memory exhausted errors crash sites and confuse users. Learn what PHP memory limits are, why WordPress needs generous memory, and how to configure them correctly.
Want the fastest WordPress hosting?
Rocket.net delivers 83ms average TTFB - up to 153% faster than competitors. Try it risk-free.
Few error messages are more alarming than seeing your WordPress site display a blank white screen alongside text like:
Fatal error: Allowed memory size of 67108864 bytes exhausted
Your site stops working, visitors see an error, and you’re left wondering what happened. This guide explains what PHP memory limits are, why WordPress needs adequate memory, and how to configure things correctly — on shared hosting, VPS, and managed WordPress plans.
What Is the PHP Memory Limit?
PHP — the programming language that powers WordPress — runs processes that consume RAM on the web server. The PHP memory limit is a server-side setting (memory_limit in PHP’s configuration) that caps how much RAM a single PHP process is allowed to use.
The default limit varies by host and PHP version but is commonly set to 32MB, 64MB, or 128MB. When a WordPress request — loading a page, running a plugin, processing a form — tries to allocate more RAM than the limit allows, PHP kills the process and throws a fatal error.
WordPress itself recommends a minimum of 64MB, with 256MB or higher recommended for sites running complex plugins or WooCommerce stores.
Why WordPress Sites Often Need More Memory
A fresh WordPress installation uses relatively little memory. The problems start as you add plugins, themes, and content:
Plugins are the biggest consumer. Each active plugin adds code that loads on every request. A page builder, an SEO plugin, a backup plugin, a security scanner, a contact form, and a caching plugin — all running simultaneously — can collectively consume far more memory than a basic installation.
WooCommerce is particularly memory-hungry. Processing a checkout involves loading product data, calculating taxes and shipping, verifying inventory, and running payment gateway code. WooCommerce recommends at least 256MB of PHP memory.
Large image uploads. When WordPress generates multiple image sizes on upload, PHP holds the full image in memory during processing. A high-resolution photo can temporarily spike memory usage significantly.
Theme frameworks. Some page builder themes and visual frameworks load substantial amounts of PHP code on every request, even for simple pages.
Database query results. Poorly optimized plugins may pull large result sets into PHP memory at once rather than paginating queries.
How to Check Your Current Memory Limit
From the WordPress Dashboard
Navigate to Tools > Site Health > Info, then expand the Server section. Look for PHP memory limit — this shows what PHP reports as its configured limit.
From the WordPress Debug Log
Add these lines to your wp-config.php temporarily:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
Then check wp-content/debug.log after a memory exhaustion event for the exact limit and the file that triggered it.
From a phpinfo() Page
Create a temporary file at your web root with this content:
<?php phpinfo(); ?>
Load it in your browser, search for memory_limit, then delete the file immediately (leaving phpinfo pages public is a security risk).
How to Increase the WordPress Memory Limit
There are several places where the memory limit can be configured. They have a hierarchy: the server’s php.ini is authoritative; WordPress’s wp-config.php and .htaccess can increase the limit only up to what the server allows.
Method 1: wp-config.php (Recommended Starting Point)
Open wp-config.php and add this line before the /* That's all, stop editing! */ comment:
define( 'WP_MEMORY_LIMIT', '256M' );
This tells WordPress to request up to 256MB for front-end PHP processes. For the WordPress admin area, add:
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
The WP_MAX_MEMORY_LIMIT constant applies to admin requests, which often need more memory (running imports, processing backups, generating reports).
Important: These constants only work if your server’s memory_limit in php.ini is set to at least that value, or to -1 (unlimited). If your host has capped PHP memory at 128MB, setting WP_MEMORY_LIMIT to 256MB in wp-config.php will have no effect.
Method 2: .htaccess (Apache Servers)
On Apache servers, you can sometimes set the PHP memory limit via .htaccess:
php_value memory_limit 256M
Add this to your site’s .htaccess file. Some shared hosts disable this directive for security reasons; if it causes a 500 error, remove it.
Method 3: php.ini
If you have access to your server’s php.ini file (common on VPS, dedicated, or managed hosting), edit or add:
memory_limit = 256M
After editing, restart PHP-FPM or your web server for the change to take effect. On cPanel hosts, look for a PHP Configuration or MultiPHP INI Editor option in the control panel.
Method 4: User.ini (PHP-FPM)
On many modern servers running PHP-FPM, you can place a .user.ini file in your web root:
memory_limit = 256M
PHP-FPM polls for changes to .user.ini files periodically (often every 5 minutes), so this can take effect without a server restart.
How Much Memory Does WordPress Actually Need?
There’s no single correct answer — it depends on your site. Here are reasonable guidelines:
| Site Type | Recommended PHP Memory |
|---|---|
| Simple blog or brochure site | 128MB |
| Business site with several plugins | 256MB |
| Membership or LMS site | 256–512MB |
| WooCommerce store | 256–512MB |
| Large WooCommerce store with many products | 512MB–1GB |
| High-traffic site with complex caching | 512MB+ |
Setting memory to an unreasonably high value isn’t dangerous, but it doesn’t fix poorly written plugins either. If a plugin is leaking memory or running inefficient queries, increasing the limit just delays the error rather than solving the root problem.
Diagnosing Memory Problems Beyond the Limit
If you’re regularly hitting memory limits even after increasing them, the problem may be a specific plugin or theme rather than a configuration issue.
Use Query Monitor. The Query Monitor plugin shows per-request PHP memory usage, query counts, and hook timing. Enable it, reproduce the high-memory condition, and look at the Memory section to see peak usage.
Deactivate plugins one by one. The classic bisection method — disable half your plugins, test, then narrow down — still works. The New Relic PHP agent or similar APM tools can give you per-function memory profiling if you have server access.
Check for memory leaks in custom code. If you have custom plugins or themes, watch for patterns like loading entire post collections into memory, storing large arrays in global scope, or running queries inside loops.
Memory Limits and Your Hosting Plan
On shared hosting, memory limits are often low (32–64MB per process) and cannot be increased without upgrading your plan. The host needs to share server RAM across many customers. When a single customer’s site starts consuming several hundred megabytes per request, it affects everyone on the same server.
This is one of the practical reasons managed WordPress hosting matters. Managed hosts allocate dedicated resources to your site and tune their server configurations specifically for WordPress workloads.
Rocket.net is a managed WordPress host built around performance. Their infrastructure includes:
- Generous PHP memory allocations tuned for WordPress, so you’re unlikely to hit arbitrary low limits that block normal plugin usage
- PHP 8.x with OPcache enabled by default, which reduces memory overhead compared to older PHP versions
- Enterprise Cloudflare integration that handles many requests at the CDN edge before they ever reach PHP, reducing the total number of PHP processes your site needs
- Redis object caching at the infrastructure level, which means WordPress can cache database results in memory rather than re-executing queries — reducing per-request PHP memory usage for database operations
For sites that are constantly bumping against memory limits, switching to managed WordPress hosting often resolves the issue entirely — not by raising a cap, but by providing a more efficient execution environment so requests use less memory in the first place.
The wp-config.php Constants Worth Knowing
While you have wp-config.php open to configure memory limits, a few related constants are worth knowing:
// Set PHP memory limit for front-end requests
define( 'WP_MEMORY_LIMIT', '256M' );
// Set PHP memory limit for admin requests (typically higher)
define( 'WP_MAX_MEMORY_LIMIT', '512M' );
// Disable all WordPress cron (use server cron instead — helps with memory)
define( 'DISABLE_WP_CRON', true );
// Limit post revision storage (reduces database load, not directly memory)
define( 'WP_POST_REVISIONS', 5 );
The DISABLE_WP_CRON constant is worth mentioning here because WP-Cron runs on page load, consuming PHP memory for scheduled tasks every time a visitor lands on your site. Offloading this to a real server cron job means those tasks don’t consume memory during regular page requests.
Summary
PHP memory limits are a frequent cause of WordPress errors, blank screens, and degraded admin performance. The key points:
- Check your current limit via Site Health or phpinfo before changing anything
- Set
WP_MEMORY_LIMITandWP_MAX_MEMORY_LIMITinwp-config.phpas a first step - Verify the server-level
php.inilimit isn’t lower than what you’ve requested - Use Query Monitor to identify which plugins or requests are consuming the most memory
- 256MB is a reasonable target for most sites; WooCommerce stores often benefit from 512MB+
If you’re repeatedly fighting memory limits despite configuration changes, the hosting environment itself may be the constraint. Managed WordPress hosting from Rocket.net provides the kind of optimized, well-resourced infrastructure that eliminates most memory limit problems — and delivers faster page loads as a side effect.
Performance tip: Your hosting provider has a bigger impact on WordPress speed than any plugin or optimization. We've tested dozens of hosts - Rocket.net consistently delivers the best results.
View Rocket.net Pricing →Ready to switch to faster WordPress hosting?
Join thousands who've made the switch to Rocket.net. Try any plan for just $1.
Start Your $1 Trial30-day money-back guarantee • Free migrations • No contracts
Related Articles
10 Best WordPress Caching Plugins for 2026 (Speed Test Results)
Comprehensive testing of the top WordPress caching plugins. Real performance data, pros/cons, and our honest recommendations for faster loading times.
How to Reduce Time to First Byte (TTFB) in WordPress
TTFB is one of the most impactful performance metrics for WordPress sites. Learn what causes slow TTFB and the most effective ways to fix it.
WordPress Image Optimization: A Complete Guide to Faster Load Times
Images are often the largest assets on a WordPress page. Learn how to compress, resize, convert to modern formats, and deliver images efficiently to dramatically improve page speed.