Memory exhausted high
WordPress "Fatal error: Allowed memory size of X bytes exhausted"
A plugin, theme, or image task asked for more memory than PHP allows, killing the request with a fatal error.
What you see
Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/wp-includes/...
What’s actually happening
A page — often wp-admin, an import, or a specific plugin screen — either shows the fatal error outright or just goes white. The byte number in the message is your current ceiling: 41943040 is 40M, 134217728 is 128M. The "tried to allocate" part is frequently small, which means you were already at the limit and the next allocation tipped it over. It can be consistent on one page and fine everywhere else.
Common causes
- PHP memory_limit is set low at the server level (32M–64M is common on cheap shared hosts) and a normal WordPress workload blows past it.
- A single plugin is leaking or loading huge datasets — bloated page builders, backup/migration plugins, and WooCommerce reports are repeat offenders.
- Image processing on upload tries to hold a large image in memory and exhausts the limit during resize.
- An import (WXR, CSV, WooCommerce products) loads too much into memory in one pass instead of batching.
- WP_MEMORY_LIMIT in wp-config is set lower than the server's php.ini value and is capping you below what the host actually allows.
How to fix it
- Raise the WordPress memory limitAdd define('WP_MEMORY_LIMIT', '256M'); near the top of wp-config.php, above the "That's all, stop editing" line. For admin-side fatals also add define('WP_MAX_MEMORY_LIMIT', '256M'); — the admin uses that constant.
- Raise the PHP limit if WordPress can't override itWP_MEMORY_LIMIT can't exceed the server's memory_limit. Set memory_limit = 256M in php.ini, or add php_value memory_limit 256M to .htaccess (Apache/mod_php), or set it in your host's PHP panel. Restart PHP-FPM and confirm in Tools > Site Health > Info > Server.
- Find the culprit when more memory only delays itIf 256M still exhausts, something is leaking. Deactivate plugins in halves and retest, or read the file path in the fatal — it often names the plugin directory. Switch to a default theme briefly to rule the theme in or out.
- Batch big importsFor large imports use a tool that processes in chunks (WP All Import, WooCommerce's native CSV importer with smaller batch sizes) instead of one giant run that loads everything into memory at once.
Stop it recurring
Set WP_MEMORY_LIMIT and the server memory_limit to 256M from day one so routine admin tasks never hit the floor.
Related errors