wp knowledge mascot PHP memory

How to Fix WordPress Memory Exhausted Error

Last Updated on April 24, 2022 by WP Knowledge Hub

One of the most common WordPress errors is the WordPress Memory Exhausted Error, but this can easily be solved by increasing your PHP memory in the wp-config file.

What is WordPress Memory Exhausted Error?

WordPress’s code is written in PHP, which is a server-side programming language. Your WordPress website is hosted on a server and a server functions much like a computer. It needs to manage how much memory it allocates efficiently to run multiple websites. Therefore WordPress has a default amount of memory assigned to it, but sometimes that may not be enough.

When your WordPress website runs out of memory because of something like a super-heavy theme, too much multimedia, or an errand plugin, you might see this error.

Fatal error: Allowed memory size of XXXXXXXX bytes exhausted (tried to allocate XXXXXXXX bytes) in /XXX/public_html/wp-includes/plugin.php on line XXX

WordPress will always try to increase its PHP memory limit to 64MB. However, 64MB is often not high enough.

If you want to increase the PHP Memory Limit, you’ll need to do the following.

Increase the PHP Memory Limit in WordPress

You will need to add a line of code to your website’s wp-config.php file. It’s located in your WordPress site’s root folder, and you will need to use an FTP client like Filezilla or Cyberduck to access it, or you can use your hosting panel’s file manage.

Just add the code below 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.

Once you are done, you can save your changes or you can re-upload your wp-config.php file back to your server and overwrite the old file if you were working locally.