Skip to main content

How to Fix a WordPress Memory Exhausted Error

A "Memory Exhausted" error occurs when a WordPress site attempts to use more memory than the current PHP configuration allows. This article provides steps for a Site Administrator to identify and resolve memory limitations on a WordPress site.

A "Memory Exhausted" error occurs when a WordPress site attempts to use more memory than the current PHP configuration allows. This article provides steps for a Site Administrator to identify and resolve memory limitations on a WordPress site.

Before you begin

You will need:

  • Administrator access to the WordPress dashboard (if available) or via FTP/File Manager.

  • Access to the site's configuration files (such as wp-config.php).

  • Knowledge of the specific WordPress site's environment.

Increase the WordPress Memory Limit

The most common way to resolve a memory exhaustion error is by defining the WP_MEMORY_LIMIT constant in your WordPress configuration file.

  1. Connect to your site using an FTP client or a File Manager.

  2. Locate the wp-config.php file in the root directory of your WordPress installation.

  3. Open wp-config.php and search for the line: define( 'WP_MEMORY_LIMIT', '256M' );

  4. If the line exists, update the value (e.g., to 512M).

  5. If the line does not exist, add the following code before the line that says /* That's all, stop editing! Happy publishing. */:

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

  6. Save the file and upload it back to your server.

Increase the PHP Memory Limit

If updating wp-config.php does not resolve the issue, the limitation may be imposed at the server level by the PHP configuration.

  1. Access your server's configuration files. This may be a php.ini or .user.ini file, depending on your hosting environment.

  2. Locate the memory_limit directive.

  3. Change the value to a higher limit, such as 512M.

  4. Save the file.

Note: The exact location and name of the configuration file may vary based on your specific hosting environment.

Confirm the result

To verify the change, you can check the current limit via the WordPress dashboard:

  • Log in to your WordPress dashboard.

  • Navigate to Tools > Site Health.

  • Select the Info tab.

  • Scroll down to the Server section and locate the PHP memory limit entry. It should reflect the value you configured (e.g., 512M).

If the error persists after increasing limits

If the error remains after increasing the limits, the issue may be caused by a specific plugin or theme consuming excessive resources.

  1. Deactivate Plugins: Temporarily deactivate all plugins. If the error disappears, reactivate them one by one until the error returns to identify the problematic plugin.

  2. Switch Theme: Switch to a default WordPress theme (such as Twenty Twenty-Four). If the error disappears, the issue is likely within your active theme's code.

  3. Check for Loops: Ensure that a plugin is not caught in a "loop" where it repeatedly requests memory until it hits the limit.

Limitations

  • Increasing the memory limit beyond what the server allows will not resolve the issue.

  • This procedure does not address underlying coding inefficiencies in a plugin or theme; it only provides more "room" for the code to run.

  • If you are unsure which file to edit or which value to set, contact Hostek support for assistance.

Did this answer your question?