How to Quickly Fix WordPress Memory Exhausted Error

Common WP Problems
0 comments
pThis post may contain affiliate links, read our disclosure for more info.

Written by Shakeel Anjum
Last updated on Mar 18, 2020

Do you ever run into the WordPress Memory Exhausted Error while installing a premium WordPress theme or plugin? If yes, then you need to read this guide.

What Is 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 /home/example/wp-includes/plugin.php on line 356

WordPress Memory Exhausted Error
WordPress Memory Exhausted Error

WordPress memory exhausted error is one of the most common 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 ways to increase the PHP memory limit in WordPress, like creating a php.ini file, editing the wp-config.php file, editing the .htaccess file or installing a plugin that will increase PHP memory for you.

I prefer creating a php.ini file to increase the PHP memory limit because it’s the safest of all, you might think installing a plugin is the easiest, but it’s not the safest, because an extra plugin can slow down your WordPress site a little bit, and may risk your website security too if it’s not regularly updated and maintained.

That’s why I always try to avoid an extra plugin when it’s possible.

I would also avoid editing the .htaccess file or wp-config file when it’s possible, so that’s why I prefer creating a php.ini file to fix the WordPress memory exhausted error.

And in this tutorial, I’,m going to show you how to create a php.ini file and use it to fix the WordPress memory exhausted error.

So, let’s get started to create a php.ini file to increase the PHP memory limit and fix WordPress memory exhausted error.

1 Create 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.

1.1 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

1.2 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; 

Above line of code will increase the PHP memory limit to 256M and In most cases, a memory limit of 256M will work fine, but if still face the same problem while installing a plugin or theme, then you can increase memory limit from 256M to 512M.

If your WordPress theme or plugin is too heavy and your WordPress dashboard doesn’t let you upload it either, then you should also increase “Maximum Upload Limit of Filesize”, and to do that, add following line of code in your php.ini below the first line of code.

upload_max_filesize = 256M;

You can also increase your “Maximum Upload Limit of Filesize” from 256M to 512M if WordPress still doesn’t allow you to upload WordPress theme or plugin because it’s file size is very big.

Also Read: How to Setup a Free SSL in WordPress

I hope this article helped you, but if you face any trouble, you can ask me in the comments section below or contact me directly and Iā€™d be more than happy to guide you through the process. šŸ™‚

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

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