WordPress PHP Memory Limit: How To Fix The Allow Memory Size Exhausted Error?

Getting an error that says “Allowed Memory Size Exhausted” in WordPress?

Initially, you may find this confusing, since you won’t know what caused the problem or how it can be fixed.

Fatal error: allowed memory size example

The good news is that this WordPress error can be fixed quickly and easily.

In this article, I’ll explain to you all what you need to know about WordPress PHP memory limit so you can fix the allow memory size exhausted error.

Let’s get started!

What is WordPress Memory Limit Exhausted Error?

The WordPress platform is written in PHP, which is a server-side language. A web server is just like any other computer.

To run multiple applications simultaneously, they need memory. PHP, like other applications, is allocated a specific amount of memory by the server administrator.

WordPress generates this error message when it needs more memory than it is allocated.

What is The PHP Memory Limit In WordPress?

The PHP memory limit for WordPress is 32MB by default. This works for websites with few pages and a limited amount of content and plugins. However, the more content you add to your website, the closer you get to your maximum memory limit.

The available memory will automatically increase to 40MB when this limit is reached, such as when you upload heavy media such as a movie.

The error message described above will appear if you still exceed the limit and you won’t be able to add new content.

How to Check Your Current PHP Memory Limit

WordPress PHP memory limit

If you access your WordPress dashboard and navigate to Tools > Site Health > Info, you can quickly determine what your PHP memory limit is.

If the memory is low, say 32M or 40M, the solution is to increase the memory allocation to your site.

Let’s see how to do that!

What Causes the “WordPress Memory Limit Exhausted” Error?

WordPress supports PHP memory limit increases beyond 40MB, but it’s worth pinpointing the cause of memory max-outs before increasing your limit. Your memory issue may be caused by more than simply available space – adding more memory will only be a temporary fix – you’ll continue to see the same error if you don’t fix the cause of it.

Memory limit issues are most often caused by two factors:

  • Poorly coded plugins: You may suffer a fatal error if you use multiple plugins (ie: backup plugins) with high memory requirements. You should always try to use the smallest number of plugins possible.
  • Too many images and movies: The PHP Memory is affected by what you put on your site. You may run out of space & memory if you upload videos and other interactive content consistently.

How to Increase the PHP Memory Limit in WordPress

If you’ve removed problematic plugins, and cleaned up your content, but you’re still getting memory errors, you might need to increase the memory limit.

This can be accomplished in two ways:

Step 1: Editing The wp-config.php file

Changing the WordPress memory limit requires editing the wp-config.php file. The file can be downloaded from the public_html folder of your site, download it and open it with your HTML editor.

When editing the wp-config.php file, identify this line.

‘That’s all, stop editing! Happy blogging.’ 

Add the following code just above:

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

With this code, WordPress is told it can use 256MB of PHP memory instead of the default 64MB. After you add this code and save/upload the wp-config file back.

You can instantly check the WordPress site again and the memory exhausted error should have disappeared. If it has not worked, you need to contact your hosting provider support.

Step 2: Contacting Your Hosting Provider to increase PHP memory limit

If editing the wp-config.php file didn’t work you need to contact your hosting provider and ask them to increase your WordPress PHP memory limit.

Final Thoughts about the PHP memory limite in WordPress (and final step if the error remains)

It is possible that WordPress is unable to increase PHP memory limits due to your web hosting provider.

Then, the PHP memory limit needs to be increased manually by your hosting company, so reach out their support.

We hope this article helped you to increase the PHP memory limit of WordPress to solve the memory exhaustion error.