If you’re a WordPress user, then you might have encountered the “WordPress Memory Exhausted” error at some point.
It’s a common problem that can be frustrating to deal with. Fortunately,
it’s not a difficult issue to fix.
In this tutorial, we will show you how to increase PHP memory and fix the memory exhausted error in WordPress.
What is the WordPress Memory Exhausted Error?
The WordPress Memory Exhausted error occurs when WordPress has used up all the available memory allocated to PHP.
This can happen when you’re trying to upload a large file, update a plugin or theme, or perform any other memory-intensive operation on your website.
When this happens, WordPress is no longer able to complete the task and will instead display a message that says, “Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)”.
Don’t worry, though – this error can be easily fixed by increasing the PHP memory limit.
How to Increase PHP Memory in WordPress
There are several ways to increase the PHP memory limit in WordPress. Here, we’ll show you the most common methods.
Method 1: Edit the wp-config.php File
The wp-config.php file is one of the most important files in your WordPress installation.
It contains all the settings for your website, including the PHP memory limit. To increase the memory limit, follow these steps:
Step 1: Log in to your website’s cPanel or access your website’s files via FTP.
Step 2: Locate the wp-config.php file in your website’s root directory.
Step 3: Download a backup copy of the file to your computer.
Step 4: Open the wp-config.php file using a text editor.
Step 5: Add the following line of code just before the line that says “That’s all, stop editing! Happy blogging.”
define(‘WP_MEMORY_LIMIT’, ‘256M’);
You can change the value “256M” to any value that you want. This will increase the PHP memory limit to the specified value.
Step 6: Save the file and upload it back to your website’s root directory.
Method 2: Edit the .htaccess File
Another way to increase the PHP memory limit is to edit the .htaccess file.
This file is used to configure the server settings and can be found in your website’s root directory. Here’s how to edit it:
Step 1: Log in to your website’s cPanel or access your website’s files via FTP.
Step 2: Locate the .htaccess file in your website’s root directory.
Step 3: Download a backup copy of the file to your computer.
Step 4: Open the .htaccess file using a text editor.
Step 5: Add the following line of code at the end of the file:
php_value memory_limit 256M
Again, you can change the value “256M” to any value that you want.
Step 6: Save the file and upload it back to your website’s root directory.
Method 3: Contact Your Web Host
If you’re not comfortable editing files on your own, you can contact your managed WordPress hosting provider and ask them to increase the PHP memory limit for you. Most web hosts will be happy to do this for you.
To do this, simply contact your web host’s support team and tell them that you’re experiencing the WordPress Memory Exhausted error. They’ll be able to increase the PHP memory limit for you.
In Conclusion
The WordPress Memory Exhausted error can be a frustrating problem to deal with, but it’s not difficult to fix.
By increasing the PHP memory limit, you can ensure that your website has enough memory