Guides /WordPress
WordPress

WordPress Memory Exhausted Error: How to Fix "Allowed Memory Size"

July 11, 20257 min readHostBible Team

The WordPress memory exhausted error looks like this: Fatal error: Allowed memory size of X bytes exhausted (tried to allocate Y bytes). PHP was trying to execute something that required more memory than it was permitted to use. Here's how to increase the limit, verify it took effect, and diagnose what's actually consuming the memory.

Why this happens

PHP has a configurable memory limit that controls how much RAM any single PHP process can use. The WordPress default is 40MB, which is sufficient for a basic install but insufficient for many plugin combinations, large media operations, WooCommerce with complex product catalogs, or sites running multiple page builder plugins simultaneously.

WordPress itself can increase this limit programmatically, up to the ceiling set by your server's PHP configuration. If your hosting plan's PHP configuration limits memory to 64MB per process, no WordPress-level change can exceed that. The WordPress setting requests more memory from PHP; PHP only grants it if the server allows it.

The error can appear on the front end (WSOD or a partial page with an error message), in wp-admin during plugin operations or media uploads, or in your debug log without visible symptoms on the page. All three indicate the same root cause.

Fix 1: Increase the limit in wp-config.php

Add this line to wp-config.php above the "That's all, stop editing!" comment:

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

This tells WordPress to request up to 256MB from PHP when loading the front end. For admin operations that require more memory (large imports, bulk image processing), you can also set a separate admin memory limit:

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

WP_MAX_MEMORY_LIMIT applies specifically to the WordPress admin area, allowing heavier operations there without raising the memory available to every front-end page load.

Fix 2: Increase the PHP memory limit directly

If the wp-config.php change doesn't resolve the error, your server's PHP configuration is capping memory below the value you specified. You can override this via .htaccess (on Apache or LiteSpeed with .htaccess overrides enabled):

php_value memory_limit 256M

Or via a custom php.ini file in your WordPress root (if your host supports user-level php.ini files):

memory_limit = 256M

In cPanel, you can also adjust the PHP memory limit directly via the MultiPHP INI Editor under the Software section. Select the PHP version your site uses and find the memory_limit directive.

Fix 3: Verify the change took effect

After making your changes, confirm the new memory limit is actually active. Create a temporary file in your WordPress root called phpinfo.php containing:

<?php phpinfo(); ?>

Visit yoursite.com/phpinfo.php and search for memory_limit. The "Local Value" column shows what PHP is currently using. If it still shows the old value, your method of increasing the limit isn't being respected by the server, try one of the other approaches. Delete this file immediately after checking: exposing server configuration details publicly is a security risk.

Fix 4: Find what's actually consuming the memory

Increasing the limit doesn't fix the underlying cause. If a plugin has a memory leak or is loading unnecessary data on every request, raising the limit buys time but not a permanent solution. Enable WP_DEBUG_LOG in wp-config.php and check /wp-content/debug.log, the memory error entry will name the file and function that exhausted the limit.

The Query Monitor plugin is the most useful tool for memory profiling on WordPress. It displays memory usage per component on each page load, showing you which plugins are the heaviest consumers and how much each contributes to the total. Install it temporarily, load a page that triggers the memory error, and look at the Memory section in the Query Monitor panel.

Common high-memory culprits: WooCommerce with large product catalogs, page builders that load all their assets on every request, social feed plugins polling APIs on page load, and backup plugins running during normal page requests instead of scheduled cron jobs.

What if the host's limit is too low?

If your hosting plan's PHP memory ceiling is too low to accommodate your site's legitimate needs, you have two options: contact support to request a higher limit (some hosts will increase it if you ask), or upgrade to a plan with higher PHP memory limits. Budget shared hosting often caps PHP memory at 64MB or 128MB, which is genuinely insufficient for a WooCommerce store or a site with multiple page builders active. This is not something you can configure around, the ceiling is enforced at the server level.

Reasonable memory targets by site type

  • Standard WordPress site (blog, brochure): 128MB is comfortable
  • WooCommerce store: 256MB is the recommended minimum
  • Complex site with page builders or membership plugins: 256–512MB
  • LMS or large-scale WooCommerce: 512MB may be warranted

If a site consistently requires more than 512MB for normal front-end page loads, there is a code quality or architecture problem that raising the memory limit further won't solve. The right response is to identify and fix the memory-hungry component.

Generous PHP limits as standard

HostBible plans come with PHP 8.2 and memory limits that accommodate real WordPress sites without needing support tickets or plan upgrades.

View Hosting Plans