2 Ways to Fix the WordPress Memory Exhausted Fatal Error

WordPress is built with the PHP language that is installed on your hosting server and works in the background. In order to function properly, WordPress requires a minimum of 64 MB PHP memory.

When the memory falls below 64 MB, WordPress tries to increase it. However, 64 MB is usually insufficient since many plugins and scripts running in the background make a demand on the available memory.

For this reason, you may sometimes experience a WordPress fatal error that reads “fatal error: allowed memory size of 41943040 bytes exhausted”.

This memory exhausted error is one of the common WordPress errors that are relatively easy to fix as you will learn below.

How to increase the WordPress PHP memory

Since this fatal error occurs due to a lack of sufficient PHP memory, you need to increase the PHP memory limit in order to resolve the error.

Method 1

Head over to your hosting file manager or use your favorite FTP program and add the following code snippet in the wp-config.php file:

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

The snippet should be added just before the closing line that reads “That’s all, stop editing! Happy blogging”.

This snippet will increase the PHP memory limit to 256 MB so that the memory exhausted error does not occur on your WordPress website.

Now, head back to the WordPress admin dashboard and open the Site Health tool under the Tools menu. Under the Info tab, click the Server dropdown to verify the available PHP memory.

WordPress memory exhausted fatal error

If the PHP memory is 256 MB or higher, which is what we set just now, it means that the increase in the PHP memory was successful and the memory exhausted fatal error should be fixed.

However, if the PHP memory is still showing 64 MB, then the wp-config.php method did not work.

Method 2

In this method, we will increase the PHP memory via the php.ini file. The php.ini file is usually located in the root WordPress directory. If your installation does not have this file, you can create it. Just log into the file manager and navigate to the public_html directory.

Now create a file and name it php.ini.

Alternatively, you can use a text editor program like Notepad to create the php.ini file. Just make sure to upload this file to the public_html directory where WordPress is installed.

Within the file, place the following code:

memory_limit = 256M

This will set the PHP memory limit to 256 MB. To verify the new memory limit follow the steps listed in Method 1.

If the memory limit is still not enhanced, then you should contact your web host and ask them to increase the PHP memory limit to resolve the memory exhausted fatal error on your website.

Check for resource-hungry plugins

Sometimes the memory exhausted error can also occur due to plugins running multiple scripts that grab a large share of scarce memory resources. So it’s a good idea to identify such plugins using the Query Monitor plugin.

This tool helps to identify plugins that use high memory and take a long time to execute. Replacing such plugins will also help to avoid the insufficient memory error.

You’ve seen two easy methods to resolve the fatal error in WordPress. Hopefully, this post was helpful to you. However, in the event the problem is still unresolved, you can check out our affordable WordPress bug fixing service where we fix all types of WordPress errors quickly and to your complete satisfaction.

Further Reading:

Download the WordPress SEO eBook

Go from WordPress SEO Zero to Hero in no time. Also receive 2 Bonus PDFs with this free eBook.

Give it a try. You will thank yourself later.

About Trishan Mehta

Trishan Mehta is a WordPress fanatic since 2009. When not WordPressing, he is busy exploring hidden natural getaways whenever he can grab an opportunity. You can grab his WordPress SEO eBook to get up to speed with WordPress SEO.

Leave a Comment