Hosting WordPress Spanish version

Support article

WordPress Memory Exhausted: How to Fix It

Fix the Fatal error: Allowed memory size exhausted message in WordPress by adjusting PHP memory and finding plugins or processes using too much.

Published: 30/06/2026 Updated: 12/07/2026

What the memory exhausted error means

The message Fatal error: Allowed memory size of ... bytes exhausted means a PHP process tried to use more memory than the server allows.

It can appear when opening a page, logging into the admin area, updating plugins, importing content, generating thumbnails, running a backup, or editing with a visual builder. Raising the limit can solve a legitimate need, but it can also mask a broken plugin or a badly configured task, so it’s worth identifying the cause rather than just raising the value indefinitely.

How to read the message

A typical error looks like:

Fatal error: Allowed memory size of 134217728 bytes exhausted
(tried to allocate 4096 bytes) in /path/file.php on line 123

134217728 bytes is roughly 128 MB. The final path points to where the failure happened, though it doesn’t always identify the culprit on its own: if it contains wp-content/plugins/plugin-name, check that plugin; if it contains wp-content/themes/theme-name, check the theme.

Step 1: check the current limit

You can check the configuration under Tools > Site Health > Info > Server, the hosting panel’s PHP section, or WP-CLI (see managing WordPress with WP-CLI).

The relevant values are memory_limit (belongs to PHP) and WP_MEMORY_LIMIT/WP_MAX_MEMORY_LIMIT (WordPress requests that can’t exceed the server’s actual restriction).

Step 2: increase memory from wp-config.php

Edit wp-config.php and add, before the final comment:

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

Don’t duplicate constants — if they already exist, just change their values. 256M is a common starting point for testing, but it’s not a universal number: it depends on the application and your plan’s limits. After saving, repeat the action that caused the error and check under Site Health whether the effective limit changed.

Step 3: change memory_limit from the panel

Look for options like Select PHP Version, PHP Settings, or MultiPHP INI Editor, find memory_limit, and select an allowed value. Don’t change every PHP limit at once — only change what’s needed and note the previous value.

Step 4: use .user.ini or php.ini

If the panel allows it, create or edit .user.ini in the site’s folder:

memory_limit = 256M

The location and how long it takes to apply depend on how PHP is configured; on PHP-FPM some changes can take a few minutes or require reloading the service.

Step 5: use .htaccess only when appropriate

On some Apache servers with PHP as a module, php_value memory_limit 256M might work, but on many PHP-FPM or FastCGI setups this line causes a 500 error. Back up .htaccess, add the directive only if your host confirms it’s supported, and remove it immediately if a 500 error shows up.

Step 6: find the process using too much memory

Plugins: deactivate the non-essential ones and reactivate them one by one (see how to deactivate WordPress plugins without admin access), paying particular attention to backup, security, analytics, import, gallery, and page-builder plugins.

Theme: switch temporarily to a default theme; if the error disappears, check the active theme and any code added to functions.php.

Imports and backups: split large files into smaller pieces and avoid running several heavy tasks at once.

Images: very large dimensions can consume a lot of memory even if the compressed file doesn’t look heavy — resize before uploading (see WordPress image upload error).

Step 7: check the logs

Temporarily turn on debug logging without showing errors to visitors (see how to turn on debug mode):

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );

Reproduce the problem and check wp-content/debug.log. Look for whether the error always repeats in the same plugin, function, or process, and turn debugging off when done.

Step 8: check cron tasks and background processes

WordPress uses wp-cron.php to run scheduled tasks; a broken process can repeat and exhaust resources. Check scheduled backups, external syncs, imports, and scheduled e-commerce actions. On high-traffic sites, it can be worth replacing WP-Cron with a real server cron task, avoiding duplicate runs.

Step 9: check that PHP and plugins are up to date

An old version of PHP, WordPress, or a plugin may have bugs that were already fixed. Before updating PHP, back up, update WordPress, plugins, and the theme, and check compatibility (see how to update PHP without breaking WordPress).

Why you shouldn’t set unlimited memory

Don’t use memory_limit = -1 on a production site unless there’s a very controlled technical reason. Allowing unlimited memory can let a broken process consume all available memory and affect the server or other sites.

Common issues

I changed WP_MEMORY_LIMIT, but the value doesn’t increase

PHP or your provider may be imposing a maximum. Change memory_limit from the panel or ask for a review.

The error only shows up in /wp-admin

Check WP_MAX_MEMORY_LIMIT, but also review the plugin or admin task causing it.

The site improves after raising memory, but fails again

There’s likely a growing consumption pattern, a repetitive task, or a larger data volume. Check logs, cron, queries, and plugins.

Frequently asked questions

How much memory does WordPress need?

There’s no single number. A simple site uses less than a store or a site with a visual builder. Start with a reasonable limit your plan allows and measure usage.

Are WP_MEMORY_LIMIT and memory_limit the same thing?

No. memory_limit is PHP’s limit. WP_MEMORY_LIMIT is a WordPress request and can’t always exceed the value PHP imposes.

Does more memory make WordPress faster?

Not necessarily. It prevents out-of-memory errors, but performance also depends on PHP, caching, queries, plugins, and images.

Should I contact support?

Yes, when you can’t change the limit, the value isn’t being applied, the error affects several sites, or you need to check the server’s real resource usage.

Conclusion

The memory exhausted error is solved by adjusting PHP’s effective limit and, above all, identifying which process is consuming resources. Raise memory in a controlled way, check the logs, and test plugins, themes, and scheduled tasks.