YOUR WORDPRESS AND WOOCOMMERCE REPAIR AGENCY

How to Fix the Fatal Error: Allowed Memory Size Exhausted in WordPress

  • 9 June 2025

If you manage a WordPress site, you may have already encountered the following fatal error:

Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)

1. Increase the PHP Memory Limit

Edit the wp-config.php file

Add the following line to your wp-config.php, just before the line /* That's all, stop editing! Happy blogging. */ :

define(‘WP_MEMORY_LIMIT’, ‘256M’);

This tells WordPress to increase the usable memory limit to 256 MB. You can try higher values if needed.

Edit the .htaccess file

Add this line to your .htaccess file:

php_value memory_limit 256M

Modify the file php.ini

If you have access to this file (on a VPS or dedicated server), edit or add the following line:

memory_limit = 256M

2. Disable Memory-Heavy Plugins and Themes

A poorly optimized plugin or theme can consume too much memory. To test this:

  1. Deactivate all plugins by renaming the wp-content/plugins folder to plugins_old.
  2. If the site works, reactivate the plugins one by one to identify the problematic one.
  3. Try switching to a default WordPress theme like “Twenty Twenty-Four.”

3. Optimize the Database

A large database can slow down your site and consume more memory. You can optimize it using a plugin like WP-Optimize or by running these MySQL queries:

OPTIMIZE TABLE wp_posts;
OPTIMIZE TABLE wp_postmeta;
OPTIMIZE TABLE wp_options;

4. Check Server Configuration

If you are on shared hosting, your provider may enforce a strict memory limit. Contact them to see if an increase is possible.

5. Upgrade to a More Powerful Hosting

As your site grows, it might be time to move to a more powerful hosting solution like a VPS or a dedicated server.

The “Allowed Memory Size Exhausted” error is common in WordPress but can be resolved by increasing the memory limit, optimizing your site, and checking your hosting environment. By following these solutions, you can improve the stability and performance of your WordPress site.

OUR BLOG

View all posts