How to Fix WordPress Memory Exhausted Error

v0 comments pThis post may contain affiliate links, read our disclosure for more info.

Written by Shakeel Anjum
Last updated on Feb 6, 2020

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

WordPress Memory Exhausted Error
WordPress Memory Exhausted Error

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)

  1. Click on + icon on the top left which says “File” to create a file (a popup box will open).
  2. Write php.ini in “New File Name” and click on the “Create New File” button.
  3. 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.
Creating php.ini file in WordPress root directory using File Manager
Creating a php.ini file in the WordPress root directory using File Manager

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 face any trouble you can ask me in the comments section below and I will be very excited to help you. 🙂

If you liked this article, please share it with your friends and subscribe to my mailing list below to get the latest WordPress tips, tricks and how-to tutorials directly into your inbox.

You May Also Like…

Sharing is caring 🙂

Please share this article to spread the word.


Master the Art of WordPress

Get exclusive access to how-to WordPress tips, tricks, and tutorials.

Thanks. You have successfully subscribed.

Shakeel Anjum

Master the Art of WordPress

Get free access to exclusive how-to WordPress tips, tricks, and tutorials that I may not publish here because of lack of time but will definitely send them to my awesome subscribers.

Thanks. You have successfully subscribed.

Pin It on Pinterest