Do you ever run into WordPress Memory Exhausted Error while installing a premium WordPress theme or plugin? You need to read this guide.
WordPress Memory Exhausted Error
When you are on a shared server, your web hosting provider allocates a very low PHP memory to your account by default, and because PHP is the core language of WordPress and nearly all WordPress plugins and themes are written in PHP, so they need memory to run efficiently.
When your theme or plugin requires more memory then the default allocated memory, then you get an error similar to this.
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
This is one of the most common and popular WordPress problem and it happens so frequently because by default PHP memory limits are set to very low if you’re on a shared hosting server.
How to Increase PHP Memory Limit in WordPress
There are many methods to increase the PHP memory limit in WordPress, like creating a php.ini file, editing the wp-config.php file, editing .htaccess file and installing a plugin.
I prefer creating a php.ini file to increase PHP memory limit, because it’s the easiest and safest, you might say installing a plugin is the easiest, but its not the safest, because an extra plugin can slow down your WordPress site a little bit, and may risk your security too if its not regularly updated, so I’ll avoid an extra plugin whenever I can.
Creating a php.ini file in the WordPress root directory to increase PHP Memory Limit
You can easily create a php.ini file in your cPanel > File Manager.
Go to your WordPress root directory from File Manager (click on public_html and select your domain if you’ve more than one WordPress sites, otherwise public_html is your root directory) and do steps listed below. (Match steps with screenshot listed below steps)
- Click on + icon on the top left which says “File” to create a file (a popup box will open).
- Write php.ini in “New File Name” and click on the “Create New File” button.
- Select the php.ini file, you recently created, and click on the “Edit” menu from the top menu list and it will open the php.ini file in a new browser.
4. Add the following line of code in your php.ini file and click save, and BOOM, your WordPress Memory Exhausted Error should be gone after completing step 4.
memory_limit = 256M;
In most cases, a memory limit of 256M will work, but if your WordPress site still doesn’t load and you get the same error, then you can change memory limit from 256M to 512M.
If your theme or plugin is too heavy and your WordPress dashboard doesn’t let you upload it, then you should also increase “Maximum Upload Limit of Filesize”, and to do that, put following code in your php.ini file as well.
upload_max_filesize = 256M;
You can also increase your “Maximum Upload Limit of Filesize” from 256M to 512M if the plugin or theme you’re trying to install is too heavy.
I hope this article helped you, but if you still face any problem then let me know in the comments section below. And I will be very thrilled to help.
If you liked this article, then please subscribe to my mailing list below to receive the latest WordPress How-to tutorials, tips, tricks, and news directly into your inbox.
Sharing is caring 🙂
Please share this article to spread the word.