How To Fix The Allowed Memory Size Exhausted Fatal Error

Molongui » Help » Troubleshooting » How To Fix The Allowed Memory Size Exhausted Fatal Error

Out-of-memory errors are one of the most common and hard-to-fix problems that PHP users run into.

Most of the time this error comes from loading more into memory than what you set up PHP to handle in one process. There are other causes, like running an old version of PHP or outdated plugins.

Update your plugins and PHP

Before taking any action, first thing you should to is to take a backup of your site and database. That won’t fix anything, but might become in handy if anything goes wrong.

Now, as a WordPress end-user, first, and easiest, thing you should do is to make sure all your plugins and theme are up to date.

Outdated plugins might be making use of PHP functions that have been deprecated and removed over time. And that might lead to the PHP fatal error we are talking about here: Allowed memory size of XXXXX bytes exhausted.

If the issue persists, you might consider updating your PHP version to the latest stable. Most hosting providers offer an easy and intuitive interface to do that, but you can follow this support article to ask your hosting provider to do it for you.

Increase PHP Memory Limit in WordPress

If above suggested actions doesn’t fix the issue, don’t worry, having up to date versions of your plugins and PHP is good practice. So you did good!

Your next course of action is to increase your PHP memory limit.

By default, WordPress automatically tries to increase PHP memory limit if it is less than 64MB. However, 64MB is often not high enough. Having said that, let’s see how to easily increase PHP memory limit in WordPress to avoid memory exhausted error.

First you need to edit the wp-config.php file on your WordPress site. It is located in your WordPress site’s root folder, and you will need to use an FTP client or file manager in your web hosting control panel.

Next, you need to paste this code in wp-config.php file just before the line that says ‘That’s all, stop editing! Happy blogging.’

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

This code tells WordPress to increase the PHP memory limit to 256MB. You can change that value to any you thing best.

Once you are done, you need to save your changes and upload your wp-config.php file back to your server.

You can now visit your WordPress site and memory exhausted error should disappear now.

If this solution does not work for you, then this means your web hosting service provider does not allow WordPress to increase PHP memory limit. You will need to ask your web hosting provider to increase your PHP memory limit manually.

Updated on January 21, 2022

Did not find a solution? We are here to help you succeed.
Open a support ticket