How do I increase WP_MEMORY_LIMIT?

Occasionally customers contact us saying that a WordPress theme or plugin shows a warning like one of these:

  • Your WP memory limit (40MB) is lower than recommended (64MB)
  • Memory Limit: 40 MB — We recommend setting memory to at least 64MB

We’ve seen this bug in WooCommerce and OptimizePress, for example.

These warnings are almost always incorrect, and can be ignored. Our PHP settings already use 200 MB for the PHP 5.x series and 250 MB for PHP 7.0 and later. Software that thinks the limit is 40 MB usually just has a bug.

Technical details

Some themes and plugins include code that simply checks the value of WP_MEMORY_LIMIT, then display a warning if it’s lower than a certain number such as 64 MB (which will make it always show a warning with the WordPress default of 40 MB).

However, WP_MEMORY_LIMIT is not the amount of memory currently available to WordPress PHP scripts. Instead, it is used in /wp-includes/default-constants.php to try to raise the PHP memory limit if (and only if) the current php memory_limit setting is lower than WP_MEMORY_LIMIT.

If the current PHP memory_limit is 250 MB (as on our systems), the WordPress WP_MEMORY_LIMIT value is not used for anything. “Increasing” it to 64M (or any number less than 250 MB) does nothing except suppress the incorrect warnings.

How can I fix it anyway?

If you want to fix this anyway to suppress the warnings, technically advanced users can add a line like this to the WordPress wp-config.php file:

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

The WordPress “editing wp-config.php” help page has more details.