BACK TO TOP

How to Fix the “Allowed Memory Size Of Bytes Exhausted” Error in WordPress

How to Fix the Allowed Memory Size Of Bytes Exhausted Error in WordPress

WordPress is the world’s most popular platform for content creation and management, especially for users with little to no coding background. Yet no matter how simple it is, sooner or later you will stumble upon a WordPress error. The troubleshooting for the errors may vary, but most of them have one thing in common – you can quickly find a solution.

Luckily, Allowed Memory Size Of Bytes Exhausted Error is one of those tame issues, with quite an easy and intuitive solution. Its error message reads: “Allowed memory size of X bytes exhausted (tried to allocate Y bytes) in your-site/some-file-path on line Z,” with X, Y, Z displayed as numbers.

Memory exhaust error

The error is caused by a lack of available server memory, mostly due to an overuse of plugins. We’ll show you how to tackle this issue by breaking it down into several smaller steps.

Solving the Error

Due to the cause of the error, two possible solutions immediately come to mind – deactivating unnecessary plugins and increasing the memory_limit parameter.

Before you proceed with troubleshooting, it is strongly recommended to create a backup of your WordPress site. You can do it manually or contact your hosting provider to help you.

Another tip before we start – wait a couple of minutes and try to refresh the page, just to make sure the error isn’t only temporary.

Deactivating Plugins

Disabling plugins is the easier and quicker of the two possible solutions to the issue. Navigate to Plugins > Installed Plugins, find a plugin and deactivate it. Clear the browser cache and reload the page. Repeat the process until the error is gone. We strongly suggest you keep these plugins deactivated.

However, if the error isn’t solved or some plugins are too valuable to be deactivated, proceed to the second solution.

Increasing Server Memory

Before we discuss the ways to increase server memory, here are a few important things you need to know.

First, increasing memory is only possible within the limits of your hosting package. If 256M isn’t enough, using higher values will likely result in a 500 internal server error. Consult with your hosting provider about the change, especially if you are using shared hosting.

Second, in order to perform the changes described in this guide, you will have to edit files using an FTP client. If you don’t feel comfortable doing this, ask your hosting provider to help you.

Now we will show you 4 methods for increasing the memory_limit. After implementing each of the following solutions and prior to running the test, don’t forget to clear the browser cache.

Onto the solutions!

Qode WordPress Themes: Top Picks
Bridge WordPress Theme Banner
Bridge

Creative Multi-Purpose WordPress Theme

Stockholm WordPress Theme
Stockholm

A Genuinely Multi-Concept Theme

Startit WordPress Theme
Startit

Fresh Startup Business Theme

Biagiott banneri
Biagiotti

Beauty and Cosmetics Shop

  1. Editing‌ the ‌wp-config.php‌ ‌file‌

To edit the wp-config.php file, connect to the server using your FTP credentials. Navigate to the root WordPress directory and find the wp-config.php file.

WP Config Edit

Edit the file using a text editor. Simply add the following line of code before the /* That’s all, stop editing! Happy blogging. */ line.

define( 'WP_MEMORY_LIMIT', '256M' );
Wp config memory increase

Save the changes and upload the edited file to the same place where the original file was located. This action will override the old file.

  1. Editing the php.ini file

The php.ini file is also located in the root WordPress directory, so you can access it the same way as the wp-config.php file.

Open the file with a text editor, search for memory_limit and change the value associated with it. Similarly, save the changes and override the old file with the new one.

If there is no file, create it and insert this line of code.

memory_limit = 256M

For some shared hosts, you have to specify your root WordPress directory in order for the memory limit increase to take effect. You can do this by adding the following code to your .htaccess file, near the top.

Change the “your_username” part with your actual cPanel username.

<IfModule mod_suphp.c> 
suPHP_ConfigPath /home/your_username/public_html
</IfModule>

Edit the .htaccess file using a text editor. You can find more details about accessing the .htaccess file in Section 4, where we describe the fourth solution to this error.

Htaccess shared host edit
  1. Changing the cPanel options

Another way to solve the error is to change the memory limit value within the cPanel. Login to cPanel using your credentials, navigate to the Software section, and click on the “MultiPHP INI Editor”.

cPanel editing

Select your domain from the dropdown list, search for the “memory_limit” attribute, and insert 256M as the respective value.

cPanel editing php.ini image-1
cPanel editing php
  1. Editing the .htaccess file

Finally, you can solve the error by editing the .htaccess file. This file is also found in the root WordPress directory. It is a server configuration file and usually hidden.

To access it, you should enable the relevant option(s) for showing hidden files within the FTP client of your choice. If you use FileZilla, as we do, navigate to the Server tab and click on “Force showing hidden files”.

Show hidden files image

Connect to the server using your FTP credentials, navigate to the root WordPress directory, and find the .htaccess file.

Htaccess edit

Open the file, search for “memory_limit” and change the value associated with it. Save the changes and override the old file with the new one.

If there is no code present, insert this line.

php_value memory_limit 256M
Htaccess memory limit increase

Final Thoughts

Using any of these methods to fix the Allowed Memory Size Of Bytes Exhausted Error takes only a few minutes. On top of showing you how to solve this issue, we’ve also tried to shed light on the sources of this problem. With this guide, not only are you better equipped for dealing with unexpected errors, but you’re also more knowledgeable about the way your website works.

Post your comment

Comments0