The WordPress memory exhausted error is a common error which every WordPress beginner may have faced. This is not such a big problem, but a small one which can be fixed within minutes. There will be some default amount of memory allocated to the various sections in your web hosting account. WordPress too have such limitations in the PHP files. Once we exhausted the allowed memory limit, it will show an error like below one
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home4/xxx/public_html/wp-includes/plugin.php on line xxx
What is Memory Exhausted Error in WordPress?
WordPress memory exhausted error normally occurs during some resource intensive operations, such as plugin installation or activation on WordPress. Each and every plugin uses some amount of memory. When we install a plugin which is at the point crossed the allowed memory limit, WordPress can’t overuse the memory than the set value. So, it shows the error. We can fix this by editing a wp-config.php which is located in the root WordPress directory in your hosting account.
WordPress memory limit vs PHP memory limit
As you may have already guessed, we used two terms in this article. The WordPress memory limit and the PHP memory limit.
WordPress memory limit is the memory limit applied to the specific WordPress site on the server. That means, a certain WordPress installation on your machine can only consume the amount of memory allocated to it defined by the WP_MEMORY_LIMIT constant in your wp-config.php file.
PHP memory limit is the memory limit that is available to PHP on your server. This is a collective memory limit for all the PHP processes running on your machine. This means, if you have multiple WordPress installations on the same server, both with a pretty good amount of traffic, you might want to increase the PHP memory limit accordingly.
How to increase WordPress memory limit?
To fix this, you must follow the steps below. If you carefully follow us, you will definitely find WordPress memory exhausted error fix by increasing the WordPress memory limit.
- Login to your hosting account control panel (Most Probably cPanel). Or your FTP server.
- Access the Web disk.
- Navigate to the root WordPress directory.
- Open wp-config.php which is located in the root WordPress directory.
- Add the following line inside the main PHP tag.
Now, you have increased the memory limit to 64M. Now check the WordPress again. If the problem still exists, you may try increasing the memory limit value or contact your hosting provider, and they will definitely help you with this issue.
How to increase PHP memory limit?
You might also have to increase the PHP memory limit on your server if you haven’t already. Set it to a higher value than the WP_MEMORY_LIMIT, because there are other scripts that PHP has to run as well. These are the steps to increase PHP memory limit –
- First of all, login to your hosting account control panel or your FTP server.
- Then, access the PHP configuration file (php.ini, usually located in “/etc/php/” folder). If you are using cPanel, you can find this file under the “Software” section.
- Now, look for the line that sets the PHP memory limit. It should look something like this:
memory_limit = 128M
- Increase the value of the memory limit to a higher value as per your requirements. For example, you can set it to 256 MB like this:
memory_limit = 256M
- Save the changes to the php.ini file.
- Restart the web server or the PHP service to apply the changes.
What is the optimum memory limit for WordPress?
The optimum memory limit for a WordPress installation will depend on the available memory on your web server. For example, if you have a server with 4 GB of RAM, setting a PHP memory limit of 512 MB would be no problem. But for a 2 GB RAM server, it might be a little too much.
As a rule of thumb, you can allocate around 10-15% of the total available memory to WordPress. Keep in mind that to make the plugins and themes work properly, there should be at least around 64 MB allocated (even though WordPress could work on less).
Also note that, higher memory allocation is not always equal to better WordPress performance. Only increase the PHP / WordPress memory limit more than 512 MB if you are facing any troubles.