Memory exhausted in PHP? How to increase the limit in WP
This guide shows why the error happens and how to fix it fast. You’ll see common triggers like plugins, themes, and heavy scripts. You’ll learn what the fatal error means and get a quick checklist to spot it. You’ll see safe steps to set WP memory in wp-config.php, edit php.ini and PHP-FPM pool files, find the plugin causing the issue, and update, disable, or replace it. You’ll also learn why memory limits matter for your monetization, how caching and efficient plugins protect revenue, and simple tips to monitor memory and keep your site stable.
Why php memory exhausted happens on your site
Your site runs on PHP and each request gets a slice of server memory. If a process—like a large import or a heavy page render—needs more than its slice, PHP throws the “Allowed memory size exhausted” error. When that overflow happens, pages slow, crash, or show the fatal error.
Often the issue starts small and grows: a new plugin, a theme update, or a long-running script can gradually use more RAM. A spike (large image upload, scheduled job) can push usage past the memory_limit, and PHP will stop the process to protect the rest of the server.
Spot patterns with logs and simple tools: enable WP_DEBUG, check the server error log, or use an APM. If the same function or plugin shows up, you have a lead. Also remember: sometimes the host’s low memory cap is the real culprit, not your code.
Common triggers: plugins, themes, heavy scripts
- Plugins—especially page builders, backups, import tools, and analytics—are common culprits.
- Themes with many built-in features or heavy image-processing routines can be greedy.
- Heavy scripts (image optimizers, complex AJAX, bulk operations) can spike memory when they loop over big datasets.
If a task processes thousands of records at once, it can exceed your PHP memory limit.
What the fatal error “Allowed memory size exhausted” means
When you see:
Fatal error: Allowed memory size of X bytes exhausted — PHP ran out of allocated memory for a specific file. The message usually includes the file and line number where the allocation was attempted. That points you to the code that failed.
The message also shows how low your current limit is and how much PHP tried to allocate. With that info you can decide to increase the limit, optimize the code, or disable the offending plugin. If you search “Memory exhausted in PHP? How to increase the limit in WP” you’ll find fixes like editing wp-config.php or php.ini — but first confirm the root cause so you’re not just papering over a leak.
Quick checklist to spot the error
- Check the server error log for the Fatal error line.
- Enable WPDEBUG (and WPDEBUG_LOG) to capture details.
- Deactivate recent plugins and switch to a default theme to isolate the cause.
- Test heavy tasks (imports) in smaller batches.
- Verify your host’s memory_limit in phpinfo() or via php.ini/.user.ini.
Set WP memory limit in wp-config.php
Edit wp-config.php when WordPress runs out of memory and shows errors like “Memory exhausted in PHP? How to increase the limit in WP”. This file is in your site root. Make a backup first, then add the memory constant near the top (below <?php and before / That’s all, stop editing! Happy blogging. /).
Add this exact line:
define(‘WPMEMORYLIMIT’, ‘256M’);
That requests 256M of PHP memory for WordPress front-end tasks. After saving, reload a page that failed. If the error stops, you fixed it. If not, bump to 512M or try server-level methods — some hosts block increases from within WordPress.
When to set WPMEMORYLIMIT and how to increase memory limit in WP
- WPMEMORYLIMIT is used for normal front-end tasks.
- For heavy admin jobs (backups, restores, large imports), WordPress may use WPMAXMEMORY_LIMIT; you may need to set both or raise the server limit.
If wp-config.php changes don’t take, edit php.ini, add memory_limit = 256M, or use .htaccess / .user.ini directives if your host allows. If you can’t change server files, open a support ticket with your host.
Backup wp-config.php before you change it
Always save a backup copy of wp-config.php before editing (download and rename it). If the site breaks, restore the copy.
Edit memory_limit in php.ini for WordPress
When edits in WordPress don’t help, change memory_limit in php.ini so PHP has more breathing room. Back up the original php.ini before editing. On many hosts you can download it with cPanel or via SSH; on managed hosts, request support.
After editing, save and restart the PHP process so the change takes effect. On shared hosting, use .user.ini or ask support to lift limits.
Locate php.ini on your server
Create a small PHP file with phpinfo() and open it in your browser; the page shows the exact path to the loaded php.ini (look for “Loaded Configuration File”). From SSH you can use:
php –ini or php -i | grep php.ini
Common paths:
- /etc/php/X/apache2/php.ini
- /etc/php/X/fpm/php.ini
- a php.ini in your site folder or .user.ini on shared hosting
Increase php memory limit and restart PHP
Find the memory_limit = line and change it to 128M, 256M, etc. Keep the trailing M. Save and verify with phpinfo() or a small test script.
Restart services:
- Apache: sudo systemctl restart apache2
- Nginx PHP-FPM: sudo systemctl restart php7.4-fpm (replace version)
On shared hosts, use the control panel or a support request. Bump in steps and test after each change.
Pick safe values like 128M or 256M
- 128M for lean sites
- 256M for WooCommerce, page builders, or large imports
Don’t set huge numbers unless your server has the RAM. Monitor performance after changes.
Increase memory limit for PHP-FPM and server
PHP-FPM pool settings can override php.ini. Change both if needed so server and PHP-FPM agree. Sensible steps: 256M → 512M or 512M → 1G for very large sites. Backup config files before editing.
If you’ve searched “Memory exhausted in PHP? How to increase the limit in WP” — the short answer is update memory_limit in your pool or php.ini, then reload PHP-FPM and test.
Edit php-fpm pool to increase memory
Locate your pool file (often /etc/php/X/fpm/pool.d/www.conf). Look for lines like:
- phpadminvalue[memory_limit] = 512M
or - phpvalue[memorylimit] = 512M
Set a modest increase, save, and remember phpadminvalue will override php.ini for that pool. Always back up before editing.
Reload php-fpm and check error logs after change
Reload the service:
sudo systemctl reload php7.4-fpm (or appropriate version)
Check logs:
- /var/log/php7.4-fpm.log
- /var/log/php-fpm/error.log
- /var/log/syslog
Use tail -f to follow output. If memory errors persist, raise the limit a bit more and re-test.
Keep php.ini and php-fpm settings matched
Make both places match to avoid confusion: set memory_limit in php.ini to the same value as the PHP-FPM pool, or rely on the pool and keep php.ini consistent.
Fix WordPress plugin memory exhausted error
If the error names a file inside wp-content/plugins/plugin-name, that’s your starting point. Steps:
- Read the error line for the file path and plugin slug.
- Disable recently added or heavy plugins, then reload the page.
- If it persists, switch to a default theme and test again.
- Use a divide-and-conquer approach: deactivate half the plugins, test, narrow down.
Decide whether to raise memory for legitimate needs or fix a greedy plugin. If the plugin is the issue and needs more RAM (complex imports, image processing), raise WPMEMORYLIMIT carefully. If it’s poorly coded, update, replace, or report it.
How you find the plugin causing the memory exhausted error
- The error message often contains the full path to the plugin file inside wp-content/plugins/plugin-name.
- If vague, deactivate half your plugins and narrow down (divide and conquer).
- Note the admin page or feature that triggers the error — it often maps to the responsible plugin.
- Clear caches between tests.
Update, disable, or replace plugins and set WPMEMORYLIMIT
- Update all plugins first — memory issues often come from old code.
- If updating doesn’t fix it, disable the plugin and find a lightweight alternative.
- If a plugin legitimately needs more memory, add define(‘WPMEMORYLIMIT’, ‘256M’); (or higher if host allows) in wp-config.php.
- Ask your host politely for a higher PHP limit if required. Don’t simply crank memory forever — balance needs and performance.
Use debug logs and Site Health to confirm the fix
Enable WP_DEBUG and log to debug.log, reproduce the error, and inspect the log for function calls and memory spikes. Run Site Health (Tools → Site Health) to catch issues and validate memory settings. This proves the problem is solved, not just hidden.
Monetization and why memory limits affect revenue
Your site’s memory limit is the size of the stage where your monetization performs. If the stage is too small, scripts crash, pages timeout, and ads or purchases fail. That means lost impressions, broken checkout flows, and fewer conversions — direct hits to your revenue, especially during traffic spikes.
When PHP hits a Memory exhausted error, visitors see errors or slow pages and leave. That reduces ad views and conversions. You can control this by tuning memory, but also fix heavy plugins. Increasing memory without addressing greedy code is like pouring water into a leaky bucket.
Memory exhausted in PHP? How to increase the limit in WP and protect monetization
When you ask “Memory exhausted in PHP? How to increase the limit in WP”, start with safe edits:
- wp-config.php: define(‘WPMEMORYLIMIT’, ‘256M’);
- php.ini: memory_limit = 256M (or higher)
- .htaccess or .user.ini: phpvalue memorylimit 256M (if allowed)
- PHP-FPM pool: phpadminvalue[memory_limit] = 512M (if needed)
After raising limits, test pages that show ads and checkout flows, keep backups, and be ready to roll back. If a single plugin consumes excessive memory, remove or replace it. Raising memory is a fix, not a cure — combine it with optimization so income stays steady during traffic spikes.
Use caching and efficient plugins to reduce memory pressure
Caching reduces the need for PHP to run on every request. Use:
- Server-side page cache and a CDN
- Lightweight plugins instead of overlapping tools
- Lazy loading, minification, and object caching for repeated queries
These reduce the chance of hitting memory limits and keep monetization stable.
Monitor memory to keep monetization stable
Use tools like Query Monitor, server dashboards, or APMs (New Relic) and set alerts for high usage. Track which plugins spike memory on specific pages. Regular monitoring helps you act before errors cost clicks.
Conclusion — quick action steps
- Reproduce the error and read the exact fatal line.
- Try define(‘WPMEMORYLIMIT’, ‘256M’); in wp-config.php.
- If needed, edit php.ini (memory_limit) and restart PHP.
- For PHP-FPM, set phpadminvalue[memory_limit] in the pool and reload.
- Isolate the plugin (deactivate/update/replace) if it’s the cause.
- Use caching, lightweight plugins, and monitoring to prevent recurrences.
If you still see “Memory exhausted in PHP? How to increase the limit in WP” after these steps, contact your host with the error message and the phpinfo() output — they can often adjust limits at the server level.

Marina is a passionate web designer who loves creating fluid and beautiful digital experiences. She works with WordPress, Elementor, and Webflow to create fast, functional, and visually stunning websites. At ReviewWebmaster.com, she writes about tools, design trends, and practical tutorials for creators of all levels.
Types of articles she writes:
“WordPress vs. Webflow: Which is Best for Your Project?”
“How to Create a Visually Stunning Website Without Hope”
“Top Landing Page Design Trends for 2025”
Why it works:
She brings a creative, accessible, and beginner-friendly perspective to the blog, perfectly complementing Lucas’s more technical and data-driven approach.
