How to Fix the WordPress Memory Exhausted Error

Have you ever encountered a fatal error screen that looks like this: Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 2348617 bytes) in /home/user/public_html/wp-includes/plugin.php on line...?

This is the infamous WordPress Memory Exhausted error. It happens when a WordPress script (usually a heavy plugin or theme) requires more memory than the default allocated amount provided by your server.

Here is exactly how you can increase your memory limit and fix this bug.

1. Increase Memory Limit in wp-config.php

This is the easiest and most common way to fix the issue. WordPress allows you to manually define the memory limit for your site.

The Fix:
Connect to your site via FTP or your host’s File Manager and edit the wp-config.php file. Add the following line just before the /* That's all, stop editing! Happy blogging. */ comment:

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

This tells WordPress to request 256 Megabytes of memory from PHP.

2. Increase Memory Limit in .htaccess

If the wp-config.php method doesn’t work, your server might require you to set the memory limit at the server configuration level.

The Fix:
Locate your .htaccess file in the root directory (make sure hidden files are visible in your FTP client). Add the following line to the file:

php_value memory_limit 256M

3. Increase Memory Limit in php.ini

If you are on a VPS or dedicated server, or if your shared host allows it, you can modify the core PHP configuration file.

The Fix:
Look for a file named php.ini or php5.ini in your root directory. If it doesn’t exist, you can create a blank text file and name it php.ini. Paste the following code inside:

memory_limit = 256M

4. What if None of This Works?

If you have tried all three methods and the error persists, it means your web host does not allow users to increase the PHP memory limit manually. You will need to contact their support team and ask them to increase the limit for your account.

Additionally, if increasing the memory to 256M or 512M still results in exhaustion errors, you likely have a rogue plugin with a severe memory leak. In that case, you should systematically disable your plugins to identify the culprit.