In case WordPress is showing “Allowed memory size exhausted” error, then this means that the limit of PHP memory of your website has been exceeded. Although increasing PHP memory will fix the issue, it is important to find out the cause of memory exhaustion first.”
Boosting the PHP memory limit in WordPress will help you fix issues like updating errors, plugin errors, White Screen of Death, and some types of 500 Internal Server Errors.
In this article, we will discuss what exactly is the PHP memory limit, the amount of memory required by WordPress, and ways to increase it safely.
Table of Contents
What is the PHP Memory Limit of WordPress?
The PHP memory limit refers to the amount of server memory available for a PHP script during the processing of the request.
Being developed on PHP, every page view, each time you install a plugin, upload images or do any other administrative action on your WordPress website involves PHP.
In case your WordPress website hits its PHP memory limit, you may encounter problems and uncompleted processes.
For instance, you could be shown the following:
| Fatal error: Allowed memory size exhausted |
Low PHP memory can also lead to problems like the WordPress White Screen of Death or some 500 Internal Server Errors.
It is important to note that PHP memory is just one component of the hosting resources you have. Even if you increase it, that alone will not solve the problems arising from the others.
What is consuming the memory?
- Newly added plugins
- Inefficient plugins
- Themes that use resources heavily
- WooCommerce
- Big data imports/exports
- Image manipulation
- WordPress updates
- Heavy database queries
- Background processes
- Malware or malicious plugins
How much PHP memory does WordPress require?
No one particular memory limit will be ideal for all websites created on WordPress. A basic blog that uses an easy to use theme and several plugins can do fine with a rather low limit setting
However, a website such as a WooCommerce store, members’ site, or a site using many plugins will need more. WordPress varies in its memory requirements based on the site, plugins, theme and workload. And in that regard, 256MB is a good benchmark to begin with when diagnosing such problems.
The most crucial aspect is not to raise the limit needlessly all the time. If you are sure that your website is constantly eating too much memory, find out why and try to fix the problem.
Find Out What Your Current PHP Memory Limit Is First
Before making any changes, see what your site is currently running with. This depends on your WordPress version, but you can view memory details below:
Tools > Site Health > Info > Server.
You can check your PHP memory through your host’s control panel as well. If you are using cPanel and have no experience with it, it will help if you read this article on what is cPanel and how to use it.
How to increase WordPress PHP Memory Limit
1. Increasing the WordPress Memory Limit using wp-config.php
One of the most common techniques is by making changes to the wp-config.php file. Make sure you have saved the copy of the file before making changes. It is usually accessible via File Manager from the cPanel or an FTP program.
Locate the following code in wp-config.php:
| /* That’s all, stop editing! Happy publishing. */ |
Add the following line above it:
| define(‘WP_MEMORY_LIMIT’, ‘256M’); |
You may also specify the memory limit for WordPress administration as:
| define(‘WP_MAX_MEMORY_LIMIT’, ‘256M’); |
Save the changes and recheck your site.
Note: This does not necessarily override the PHP memory_limit set on the server. If the PHP memory limit on the server is lower than what you have specified, then it cannot take that value.
2. Increasing PHP Memory Limit Using cPanel
Another way to increase PHP memory limit, if you use cPanel and your hosting company permits changing PHP options for clients, is a more elegant solution.
Simply log into cPanel and find MultiPHP INI Editor, Select PHP Version or some other PHP settings editor utility.
Search for:
| memory_limit |
Then increase its size to something reasonable like:
| 256M |
Then try the website again.
With HarmonWeb, you will be able to use cPanel via your HarmonWeb Client Area.
3. Modifying php.ini When Necessary
Another choice would be configuring through a php.ini file.
Depending on your hosting system, it might be possible for you to modify/create a php.ini file and set:
| memory_limit = 256M |
The above process relies upon the configuration of PHP in the web server environment. Some hosting services limit the ability of accounts to modify their PHP settings.
Setting up your PHP memory limit can be conveniently done via the PHP Selector feature on CloudLinux, accessible from your HarmonWeb Client Area or cPanel.
4. Be Wary of .htaccess Configuration
While some server environments may support the modification of PHP options via the .htaccess file, this is not always the case.
In certain setups, when a specific PHP handler is being used, PHP setting such as this one:
| php_value memory_limit 256M |
will be valid, whereas on another setup it will cause an error.
Thus, you should not be adding PHP directives to ‘.htaccess’ blindly.
In case your website starts showing a 500 error, then you should undo that modification instantly.
For further assistance, refer to HarmonWeb’s tips for solving 500 Internal Server Error in WordPress 500 Internal Server Error in WordPress.
5. What If You Are Unable to Boost the PHP Memory Limit?
This is when your hosting environment plays an important role. Your hosting provider may set limits to the amount of memory, CPU, processes, database connections, and other resources you have for your account.
Under such conditions, editing wp-config.php won’t help you get additional physical resources from the server.The HarmonWeb hosts its guide about shared server resources here.
In case your site has been exhausting the resources frequently, then you might have to do the following:
- Deleting any unnecessary plugins
- Using good quality plugins that don’t exhaust resources
- Database optimization
- Elimination of any unnecessary background tasks
- Optimization of images and other media files
- Caching
- Hosting upgrade
We further suggests that you should investigate the reason behind memory exhaustion before increasing memory limit. Finding out the reason behind memory exhaustion will help prevent bugs in the hidden code from taking up all the memory on the server.
6. Do Not Confuse Your PHP Memory with WordPress Speed
Allocating more memory to PHP will enable your website to perform more complex tasks, but it doesn’t necessarily increase increase speed in WordPress.
If your site is slow, you need to look into other aspects like server speed, caching, database queries, images, plug-ins, themes, and even your web host.
For instance, the HarmonWeb’s article on how to make a slow WordPress site faster can assist you with identifying various performance issues.
You will also discover more about server response time and Core Web Vitals.
When Is It Time to Raise Your PHP Memory Limit?
If you always experience errors because of not enough PHP memory, especially after adding an expensive plugin, theme, or feature, then raise your PHP memory limit.
Nevertheless, you should not raise the limit just because you can. When a fairly straightforward site is using more memory than normal, the underlying cause needs to be identified. The problem could be a broken plugin, inefficient code in a theme, a flawed query in the database, or an incorrectly set up application.
One of the reasons for the failure of WordPress auto updates includes not enough server resources.
Frequently Asked Questions
Question: How much should the PHP memory limit be set for WordPress?
Answer: There isn’t any set value, but you can consider setting it to 256 MB initially. It may vary based on the size of your website, and accordingly the requirement might increase or decrease.
Question: Will increasing PHP memory cause problems with WordPress?
Answer: Increasing the limit in itself usually doesn’t cause problems to WordPress, as long as the limit set is valid in your hosting environment. Improperly changing wp-config.php, .htaccess, or PHP configurations may, however, lead to errors.
Question: Why does WordPress still display the memory error despite increasing the limit?
Answer: There could be a situation where the PHP limit in the server is lower than the one set. There might also be a case where some other resource gets exhausted.
Question: Should I increase PHP memory rather than switching my hosting plan?
Answer: Not strictly. In case you notice that your site is constantly hitting the limit of your hosting account resources, it would be more beneficial to switch to another more suitable environment.
Conclusion
Increasing the PHP memory limit for WordPress can be an easy fix to problems related to memory, but you have to be careful while doing so. You need to first find out your existing limit and what is taking up the memory and then implement it.
Changing wp-config.php file or PHP configuration settings via cPanel will be enough for most people, but if the limitation of the PHP memory is not allowed by your host, then the issue could be related to the resources on your current hosting package
If you keep getting WordPress errors or your site is not performing well, you can opt for HarmonWeb WordPress hosting as the ideal hosting platform for your WordPress sites.
Need Extra PHP Memory?
If you cannot change the PHP memory limit in your hosting account appropriately, it may be the easiest thing to do to upgrade your hosting setup.
Take a look at HarmonWeb WordPress Hosting and get what your website needs!


