How To Increase PHP Memory Limit To Fix Fatal Error Allowed Memory Size Exhausted

It is really frustrating to see errors like the error “Allowed memory size exhausted”, but do you know there is a way to fix this error forever?

I’m gonna show you 3 genuine ways to increase PHP memory limit quickly in this article. However, there are some downsides of it as well that you should know. Like, it can break your site if you raise the PHP memory limit too much (like 900MB). We’ll discuss more it later in this post.

But first, we should know what exactly is PHP memory and how it helps/works.

What is the PHP Memory limit?

PHP memory limit in simple words means the maximum amount of memory a script can use on your website. Let’s know more about it in detail.

Your website gets power from servers. These servers are just like computers because they use RAM, Processers, and Storage – also known as memory.

The most important part of the server is RAM. Everything that works on your site, uses a bit of RAM. If the plugin, theme, or app is too heavy, then it would use more memory (RAM, Storage, and Processers). If your site runs out of memory, then it would show you an error (Blank white screen or Critical error), or take too much time to load.

Normally, every host handles this well, but in case your host has given you very little memory to work with, then you may encounter this problem almost every time you install a plugin or a new theme.

Why Does Every Host Set A PHP Memory Limit?

Having a PHP memory limit is really important because it saves your server from crashing. Suppose you have installed a heavy plugin that you have downloaded from a site, and the next day, that plugin gets an error and stuck in an endless loop and just keeps taking up more and more server resources.

When something like this happens, the memory limit helps to put a hard stop on that before it can impact your entire server.

Most plugins only take a tiny amount of RAM because their scripts are very small. So, this problem almost never happens unless you try to run a program that requires more server resources in one script than most programs will ever need as a whole.

What “Fatal Error Allowed Memory Size Exhausted” Looks Like?

When something like this happens, most people see a completely white screen. The error appears either on your entire site or some parts of your site.

This error looks scary because it not only impacts your backend but also the front end. Every second feels terrible because we lose a lot of visitors because of it. In this situation, most people panic and begins to search for a solution. However, the most reliable thing to do in that situation is to call customer support.

Customer support staffs are professional and can fix your site in minutes, also, you won’t have to do anything in that, they’ll handle everything.

How To Increase PHP Memory Limit

As I said earlier, I’m gonna show three ways to do that, but first, check whats the current PHP memory limit of your WordPress site. You can do this by visiting the Tools>Site Health section of WordPress.

Once you open the Site Health section, click on info, and under Servers, you’ll be able to check the current PHP memory limit.

Tools>Site Health>Info>Server

If you see less than 256MB, then get ready to raise it, but if it is already high like 256MB, then there is a high chance that it’s not a PHP memory limit issue. You may be getting the error because of a broken plugin or theme.

Solution 1: Use Your cPanel To Raise The Limit

cPanel gives you every option to remove the error you’re getting. The steps are easy, however, I still suggest creating a backup before you do that.

Step 1: Log in to your cPanel

You can use the link that you had received after purchasing your hosting or use YourDomain.com/cpanel. If you don’t remember your password, click on forget, you’ll receive a link to reset the password.

Step 2: Under The Software Section, Click On MultiPHP INI Editor

Once you’re logged in, scroll down a bit, and you’ll find the Software section, under it MultiPHP INI Editor is visible. Click on it. You can also use the search tab located at the top to find it.

Step 3: Select Your Domain For Which You Want To Increase Memory Limit From The Drop Down

You’ll see two modes in MultiPHP INI Editor, Basic, and Editor, you won’t need to go o Editor mode, stay on Basic mode.

Step 4: Look For Memory_limit

Use ctrl+F keys or scroll down a bit to find it. on the right side, you’ll how much memory is allowed for your WordPress site. If you see 32MB, 64MB, or even 128MB, then change it to 256MB, and click on Apply.

Don’t forget to click Apply, otherwise, the memory limit won’t change.

Solution 2: The Plugin Method

Surprisingly, there is one plugin available in the plugin section that can help us increase the memory faster. I don’t why nobody talks about it, maybe because this plugin only has about 5,000 active installations which are quite low.

The plugin I’m gonna use is called “WordPress WP Memory Limit, Memory Usage, Server Memory, and Health Plugin”

Let’s see how to use it.

Step 1: Install and Activate

Search WordPress “WP Memory Limit” in the search tab of the plugin section. Once you find it, click on install then activate.

Step 2: Go to the Settings and Click on Update PHP Memory Limit

Once the plugin is activated, you would see a settings option, click on it to reach the dashboard of the plugin. You’ll see the 5 options menu, click on Update PHP Memory limit.

Step 3: Select the PHP Memory Limit (Choose 256MB)

Here comes the final step. Select the new memory limit, and click on update. You’ll see a green notification, stating “database updated”

Read More:

How To Make Fewer HTTP Requests (12 Master Tips)

How To Break (Split) WordPress Posts Into Multiple Pages Effectively

How To Setup EWWW Image Optimizer (Compress Upto 80%)

Solution 3: Edit Wp-Config.PHP File

This step is a little complicated, especially for beginners. I recommend using the cPanel method if you haven’t had much experience with the Wp-Config.PHP file before.

Still, I’ll do my best to present it in the easiest way so that you can follow along without much difficulty.

Step 1: Log in to your cPanel

You’ll need to log in to your cPanel to find the Wp-Config.PHP file. If you don’t remember your password, then click on forgot password to reset it.

Step 2: Open File Manager (visible under Files)

File Manager is where all your site data is located. Open it to find the Wp-Config.PHP file.

Step 3: Find Public_html Folder and Open it

Look at the left side menu or simply use the search tab or ctrl+F key to find the Public_html folder. Once you find it, click on it to expand it. You’ll see some new folders or files appear on the right side. Find Wp-Config.PHP file from there by using the ctrl+F key or search tab.

Right-click on the WP-Config.PHP to see the edit option. Click on the edit option. Once you click on the edit option and ignore the warning, you will a default text editor.

Step 4: Add/Modify the code

Now, simply add the code shown below before /* That’s all, stop editing! Happy blogging. */

define( 'WP_MEMORY_LIMIT', '256M' );

look at the image below for help.

Note: The screenshot above does not give/show the entire file because it normally contains sensitive information, and most of it is unrelated to your requirements right now.

The part you should look for is the line reading, “That’s all, stop editing! Happy publishing”. This is where the file ends.

Typically, you can increase the limit to another figure, but this is normally more than enough for most sites. After you join the line to your wp-config.php file, don’t forget to save your changes and close it.

Now, open your WordPress site again and go to the Tools > Site Health > Info tab to look at your server settings. If your PHP memory limit is still giving the same number as before, it may be due to your web hosting provider.

In some rare cases, your web host will not allow you to make direct changes to your PHP memory limit. In that case, contact your web host asap.

It’s A Wrap

Facing memory exhausted errors can be really frustrating, especially, for beginners. I’ve encountered it many times and found that there are three ways to solve it. In my opinion, the easiest way to solve this is by installing a plugin or using your cPanel. You can also solve this issue by editing your Wp-Config.PHP file by adding the code – define( ‘WP_MEMORY_LIMIT’,’256M’);

That’s all, Thanks For Reading!

Check out my other works:

How To Fix “There Has Been A Critical Error On Your Website” (Screenshots)

How To Eliminate Render Blocking Resources (Powerful Ways)

How To Detect Plugins Which Are Slowing Down Your WordPress Site (Ultimate Guide)

Default image
Sumit

Sumit is a regular contributor to Hostinggrow.com. He has 6 years of experience in blogging, and he loves football, his favorite player is - Lionel Messi (GOAT), but he has no hate for Ronaldo.

Articles: 54

Leave a Reply

Your email address will not be published.