How to Fix WordPress Memory Exhausted Error (Allowed Memory Size)

August 15, 2026

To fix the WordPress memory exhausted error, increase the PHP memory limit by editing the wp-config.php file or the php.ini file.

The WordPress memory exhausted error is a common issue that occurs when the PHP memory limit is too low, causing your website to crash or display a fatal error message. This error can be frustrating, especially if you’re not familiar with coding or server management. However, it’s relatively easy to fix by increasing the PHP memory limit. In this article, we’ll guide you through the steps to increase the PHP memory limit and fix the WordPress memory exhausted error.

Understanding the WordPress Memory Exhausted Error

The WordPress memory exhausted error occurs when the PHP memory limit is exceeded, causing your website to run out of memory. This can happen when you’re running multiple plugins, themes, or scripts that consume a lot of memory. The error message typically looks like this: “Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes)”. To fix this error, you need to increase the PHP memory limit to allow your website to use more memory.

  • Check the error message to determine the current memory limit and the amount of memory being used.
  • Identify the plugins or themes that are consuming the most memory.
  • Consider upgrading your server or hosting plan to increase the available memory.

Increasing the PHP Memory Limit via wp-config.php

To increase the PHP memory limit via the wp-config.php file, follow these steps:

  1. Log in to your website’s file manager or FTP client.
  2. Navigate to the root directory of your website and locate the wp-config.php file.
  3. Open the wp-config.php file in a text editor and add the following line of code: define(‘WP_MEMORY_LIMIT’, ‘256M’);
  4. Save the changes and upload the updated file back to your website.

Alternatively, you can also increase the PHP memory limit via the php.ini file. This method is more advanced and requires access to your server’s configuration files.

Increasing the PHP Memory Limit via php.ini

To increase the PHP memory limit via the php.ini file, follow these steps:

  1. Log in to your server’s control panel or file manager.
  2. Navigate to the php.ini file, usually located in the /etc/php/ or /usr/local/lib/php/ directory.
  3. Open the php.ini file in a text editor and locate the line that starts with “memory_limit”.
  4. Update the memory limit value to a higher value, such as 256M or 512M.
  5. Save the changes and restart your server or PHP service.

It’s also important to note that some hosting providers may have restrictions on the maximum allowed memory limit. In such cases, you may need to contact your hosting provider to request an increase in the memory limit.

Choosing the Right PHP Memory Limit

The ideal PHP memory limit depends on your website’s specific needs and requirements. A higher memory limit can improve performance, but it also increases the risk of memory exhaustion. Here are some general guidelines to consider:

  • For small websites with minimal plugins and themes, a memory limit of 128M to 256M may be sufficient.
  • For medium-sized websites with multiple plugins and themes, a memory limit of 256M to 512M may be required.
  • For large websites with complex plugins and themes, a memory limit of 512M to 1024M or higher may be necessary.

It’s also important to monitor your website’s memory usage and adjust the PHP memory limit accordingly. You can use tools like server monitoring services to track your website’s memory usage and receive alerts when the memory limit is exceeded.

Optimizing WordPress for Better Performance

In addition to increasing the PHP memory limit, there are several other ways to optimize WordPress for better performance. Here are some tips:

  • Use a caching plugin like W3 Total Cache or WP Super Cache to reduce the load on your server.
  • Optimize your images and compress them using tools like TinyPNG or ImageOptim.
  • Use a content delivery network (CDN) to distribute your content and reduce the load on your server.
  • Consider using a marketing automation platform to streamline your workflow and improve efficiency.

Troubleshooting Common Issues

When increasing the PHP memory limit, you may encounter some common issues, such as:

  • Memory limit errors: If you’re still experiencing memory limit errors after increasing the PHP memory limit, you may need to further optimize your website or consider upgrading your server.
  • Plugin conflicts: Some plugins may not be compatible with the increased memory limit, causing conflicts or errors. In such cases, you may need to disable or replace the problematic plugin.
  • Server errors: If you’re experiencing server errors after increasing the PHP memory limit, you may need to contact your hosting provider to request assistance.

Debugging Tips

To debug common issues, you can use tools like the WordPress debug mode or server logs to identify the source of the problem. Here are some tips:

  • Enable the WordPress debug mode by adding the following line of code to your wp-config.php file: define(‘WP_DEBUG’, true);
  • Check the server logs to identify any errors or warnings that may be related to the issue.
  • Use a debugging plugin like Debug Bar or WP Debugging to monitor your website’s performance and identify potential issues.

In conclusion, fixing the WordPress memory exhausted error requires increasing the PHP memory limit and optimizing your website for better performance. By following the steps outlined in this article, you can resolve the error and improve your website’s overall performance. Remember to monitor your website’s memory usage and adjust the PHP memory limit accordingly. If you’re experiencing any issues or need further assistance, don’t hesitate to contact us for help.

Disclosure: This post contains affiliate links. We may earn a commission if you purchase through them, at no extra cost to you.

Close-up of HTML and PHP code on screen showing error message and login form data.
Close-up of HTML and PHP code on screen showing error message and login form data.
Focused view of programming code displayed on a laptop, ideal for tech and coding themes.
Focused view of programming code displayed on a laptop, ideal for tech and coding themes.

What is the WordPress memory exhausted error?

The WordPress memory exhausted error occurs when the PHP memory limit is exceeded, causing your website to run out of memory.

How do I increase the PHP memory limit?

You can increase the PHP memory limit by editing the wp-config.php file or the php.ini file.

What is the ideal PHP memory limit for my website?

The ideal PHP memory limit depends on your website’s specific needs and requirements. A higher memory limit can improve performance, but it also increases the risk of memory exhaustion.

How can I optimize my WordPress website for better performance?

You can optimize your WordPress website by using a caching plugin, optimizing your images, and using a content delivery network (CDN).

Leave a Comment