WordPress Memory Exhausted Error Fix – Increase PHP Memory Limit
Sometimes when you perform any task on WordPress, you might get an error like: “fatal error: allowed memory size of 67108864 bytes exhausted”. It’s a very common WordPress error and mostly occurs on WooCommerce sites as these sites require more memory to efficiently run different applications at the same time. But, you can easily fix WordPress memory exhausted error by increasing PHP memory limit.
In this article, I will share how to fix WordPress memory exhausted error by increasing PHP memory limit.
Why WordPress memory exhausted error occurs?
By default, WordPress tries to increase PHP memory limit to 40MB which is not enough sometimes. If you run a big WooCommerce site or install so many plugins, then WordPress requires more memory to smoothly run all the applications.
But the problem starts when WordPress reaches the maximum memory limit. You may see an error like this:
The solution is to increase PHP memory limit in WordPress.
How to Increase PHP Memory Limit in WordPress
Increasing the PHP memory limit is a very easy task. All you need to paste a simple line of code in your wp-config.php file. The file is located in your WordPress root folder.
You can access the root folder by using an FTP client or from File Manager in cPanel.
Now edit the wp-config.php file and paste the following code before the line: “/* That’s all, stop editing! Happy blogging. */”.
define( 'WP_MEMORY_LIMIT', '256M' );
Once you are done, don’t forget to save the file.
This code increases the WordPress PHP memory limit to 256MB. Normally, WooCommerce sites recommend at least 128MB memory size. But sometimes 128MB isn’t enough in case you are running a big WordPress site. So, 256M should be enough for all sites.
That’s it. The WordPress memory exhausted error should have gone now.
Increase WordPress PHP Memory Limit Using .htaccess
There is another easy way you can increase PHP memory limit using the .htaccess file.
First, go to the root directory of your WordPress site and find the .htaccess file. As it is a dot (.) file, you may not see the file.
From the file manager setting check “show hidden files” option and you are good to go.
Edit the .htaccess file and add the following code at the end.
php_value memory_limit 256M
Once finished, click on save to update the file.
Note: I also recommend you to update your PHP to the latest version to improve your site’s overall performance.
If you are using a cPanel hosting, then you can do it easily.
Log in to your hosting cPanel and click on the Select PHP Version option.
After that, it will show you which PHP version your site is running on. Click on the drop down option and select the latest PHP version and click on Set as current.
In case this solution doesn’t work for you, you need to contact your web hosting provider and ask them to increase PHP memory limit manually.
That’s all. I hope this tutorial helped you to fix WordPress memory exhausted error.
Did you face this type of error while activating a plugin? Which method from above worked for you? Let us know in the comment section.
Related WordPress articles,
- How to Monitor Logged in User Activity in WordPress
- How to Manually Update WordPress, Plugins, and Themes
*This post may have affiliate links, which means I may receive a small fee if you choose to purchase through my links (at no extra cost to you). This helps us to keep WPMyWeb up and running and up-to-date. Thank you if you use our links, we really appreciate it! Learn more.