How to Resolve ‘Allowed Memory Size Exhausted’ Error in WordPress
Resolving the ‘Allowed Memory Size Exhausted’ Error in WordPress is all about increasing the PHP memory limit in WordPress. There are several ways to go about it. Any one of these three ways should solve the problem:
- Editing the wp-config.php file
- Editing the php.ini file
- Editing the .htaccess file,
However, you need to analyze the additional memory that would be required because it will be different across different installs.
Editing the wp-config.php file
This is the most popular and simple way of increasing the PHP memory limit in WordPress. In this method, we will be editing the wp-config.php file. Ensure that you back up the file on your local computer or desktop before editing it. This helps you in case you need to restore the file to an earlier state.
Now, to resolve the ‘Allowed Memory Size Exhausted’ error, just add the code below in the file before the line that says “That’s all, stop editing! Happy blogging”.
define( 'WP_MEMORY_LIMIT', '256M' );
Once you’ve made the edit, go to your website URL to see if the error is resolved. In some instances, this method may not work. This might happen if you have shared hosting and the hosting provider does not allow such a change. In that case, you need to contact your hosting provider to resolve this issue.
Editing the php.ini file
The php.ini file is a configuration file that can be used to control resource limits. It is read when a PHP script is executed or else when PHP starts. In the case of a live install, you will find the php.ini file within the root of your install i.e. within the /public_html/ folder. In most cases, the file is set up by your host. For instance, if you’re using Cpanel as your control panel, ensure that the “Show Hidden Files” box is checked and hit Go. Be sure to back up the file before editing it.
Now, open the file and add the following line in the code:
Finally, hit save and close the file.
Editing the .htaccess file
If editing the php.ini file didn’t work for increasing the PHP limit in WordPress, you can try editing the .htaccess file. You will find this file located within the root of your WordPress files. It is advisable to back up this file in case you need the original one.
To increase the memory limit, add the following code to the bottom of the file:
php_value memory_limit 256M
Save the changes and check if the ‘Allowed Memory Size Exhausted’ error is resolved.
These were three easy and quick ways in which you can resolve the ‘Allowed Memory Size Exhausted’ error in WordPress.
- Check out our recommendations for the best wordpress web hosting.