TLDR: If you see fatal errors like “Allowed memory size exhausted” or you run heavy plugins, you can safely increase WordPress memory by editing wp-config.php, php.ini, or .htaccess, or by asking your host. I’ll walk you through each method, show troubleshooting tips, explain what to avoid, and share the exact code snippets I used.
I still remember the first time my site crashed under a heavy plugin update. I opened the front page and instead of my carefully styled homepage I saw a cold white screen and the dreaded phrase: allowed memory size exhausted. I felt that sinking feeling you get when something you built stops working. That moment forced me to learn how WordPress handles PHP memory and how to safely increase memory limits without breaking the site or getting blacklisted by my host.
What is the WordPress memory limit?
The WordPress memory limit is the maximum amount of PHP memory allocated to WordPress processes. PHP has its own memory_limit setting, and WordPress can request a higher limit using constants like WP_MEMORY_LIMIT inside wp-config.php. As you know, themes and plugins consume memory; media-heavy pages, importers, and page builders are common culprits that push usage beyond default allocations.
Why does it matter?
Low memory results in fatal errors, failed imports, broken admin screens, and slow performance. However, simply increasing memory without diagnosing the root cause can mask deeper issues like memory leaks or inefficient plugins. When I increased memory for a staging site, it fixed immediate crashes but also surfaced a plugin that was hogging resources. That allowed me to replace it and keep memory increases minimal and sensible.
How much memory do you need?
There is no single answer, but common safe targets are 128M for most blogs, 256M for shops and complex sites, and 512M for intensive operations such as large imports or image processing. Check your PHP info and current usage before changing values. In general, aim for the lowest value that solves the problem, because higher values can hide inefficiencies and some hosts limit allocations.
How to increase WordPress memory limit (practical methods)
Let’s break it down into the methods I used, ordered from the least invasive to the most. Use the one that fits your environment.
Edit wp-config.php (the most common method)
Open wp-config.php in your WordPress root and add one of these lines above “Thats all, stop editing” comment. I preferred this because it applies directly to WordPress without touching server-wide settings.
- define(‘WP_MEMORY_LIMIT’, ‘256M’); // increases memory for the front-end and admin
- define(‘WP_MAX_MEMORY_LIMIT’, ‘512M’); // increases memory for admin-intensive tasks like updates and imports
After saving, reload your site and test the actions that were failing. If the admin tasks still fail, try bumping WP_MAX_MEMORY_LIMIT temporarily while you run the job, then revert.
Edit php.ini (when you control PHP settings)
If your host allows custom php.ini files, change or add this line:
- memory_limit = 256M
You may need to restart PHP-FPM or your web server for changes to apply. In shared environments, php.ini overrides may be disallowed; in that case try user-level changes or contact support.
For Apache servers where php.ini edits are blocked, you can try adding this to .htaccess in your WordPress root:
- php_value memory_limit 256M
Note: Some hosts block php_value in .htaccess and will return a 500 error. If that happens, remove the line and try another method or consult your host.
Use cPanel or your hosting dashboard
Many hosts provide a PHP settings panel where you can increase memory_limit per site or per PHP version. I often prefer this because it is persistent and supported by the host. If you’re unsure where to find it, search for MultiPHP INI Editor or PHP Selector in cPanel.
Ask your host
If you cant change server settings, contact support. Explain the error and the action causing it. In my case, a host support technician increased the global limit and pointed out a plugin conflict that explained the heavy usage.
Temporary increases for heavy operations
For one-off operations like large imports, set WP_MAX_MEMORY_LIMIT higher just for the process and then revert. That prevents long-term resource consumption and helps you spot inefficient tasks.
Troubleshooting and verification
To confirm the change, create a phpinfo.php file with <?php phpinfo(); ?> and open it in your browser. Search for memory_limit to see the active value. For WordPress-specific limits, use a plugin like Query Monitor to view runtime memory usage and peak consumption, or check error logs for allowed memory size exhausted messages.
What to avoid
Dont set an arbitrarily large number and forget it. Some hosts cap memory and raising it on your own may have no effect. Avoid blindly editing core files in themes or plugins to force memory changes. Never keep extremely high values (like 2G) on shared hosting—this can trigger account suspension or slow noisy neighbors on the same server.
Performance and root cause analysis
Increasing memory is often a band-aid. I highly recommend checking for heavy plugins, inefficient image sizes, and database bloat. In fact, cleaning your WordPress database can reduce memory pressure during backups and queries, so I ran a cleanup after increasing memory and the site became more stable. If you want to automate inspections, use lightweight monitoring tools and perform load testing in a staging environment before applying changes on production.
When I optimized image handling and database queries, the memory spikes reduced and I could lower WP_MEMORY_LIMIT back to a safer value.
Quick checklist (do this in order)
- Backup your site and database
- Check current memory usage and phpinfo
- Try wp-config.php edits first
- If blocked, try php.ini or .htaccess depending on server
- Contact host if you cant change settings
- Diagnose plugins, images, and database if memory use remains high
How to revert changes safely
If a change breaks your site, revert the lines you added to wp-config.php or php.ini and restore your backup. For .htaccess errors, remove the added php_value line to restore site access immediately.
When increasing memory is the right move
Increase memory when you consistently hit memory limits during normal operations like plugin updates, scheduled tasks, or importing content. If increasing memory resolves the issue and memory usage remains moderate, the change is justified. If usage stays high, dig deeper into the underlying problem.
What I learned the hard way
In my early days I increased memory to crazy numbers to avoid errors. That turned out to be a mistake because it masked an inefficient plugin that was loading massive data sets into memory. After removing the plugin and cleaning up the database, I reduced memory back to healthy levels and the site performed better. To this day I use a minimal increase as a troubleshooting step rather than a default fix.
Frequently Asked Questions
How do I know if WordPress needs more memory?
You usually see errors like “Allowed memory size of X bytes exhausted” in your error logs or on-screen if WP_DEBUG is enabled. You may also notice admin tasks failing, image processing stalling, or imports dying mid-way. Use phpinfo or Query Monitor to inspect current memory_limit and real-time usage.
Can I set memory in wp-config.php on any host?
Most WordPress setups accept WP_MEMORY_LIMIT constants, but some shared hosts override or ignore them. If the change has no effect, try php.ini, .htaccess, or contact your host for support.
Will increasing memory slow my site?
No. Increasing the memory allocation does not by itself slow your site. However, permitting high memory consumption can allow inefficient code to run that may slow processes. That’s why it is important to combine memory increases with performance audits.
Is it safe to set WP_MAX_MEMORY_LIMIT to 512M?
It is safe if your host supports it and your site legitimately needs it for admin tasks. Always set the lowest value that solves the issue and monitor for sustained high usage. If you are on shared hosting, check with support first.
How do I revert changes if something breaks?
Restore your backup or remove the lines you added to wp-config.php, php.ini, or .htaccess. For code-level errors, enable WP_DEBUG_LOG to capture the issue and fix the offending plugin or theme.
To summarize, increasing WordPress memory is a straightforward fix for common PHP exhaustion errors, but it should be applied carefully. Back up the site, try wp-config.php edits first, verify with phpinfo, and use increases as a step in troubleshooting rather than a permanent band-aid. In addition, clean up heavy plugins and the database to keep memory demands reasonable.
As a final tip: after you fix the memory issue, consider running a lightweight health audit and a backup to ensure stability long-term. If you want, you can also review strategies to optimize images and caching for better memory and performance balance.
For additional maintenance tasks I often run, I sometimes need to clean WordPress database to reduce bloat and query cost. When troubleshooting performance spikes I also remember to purge cache WordPress before re-testing changes. And if you are planning major changes or migrations, following a guide to migrate WordPress site safely will keep the process predictable and low risk.