How do I increase WP_MEMORY_LIMIT?
Occasionally customers contact us saying that a WordPress theme or plugin shows a warning mentioning a “40 MB” WordPress “memory limit” or “ WP_MEMORY_LIMIT”, like one of these examples:
- Your WP memory limit (40MB) is lower than recommended (64MB)
- Memory Limit: 40 MB — We recommend setting memory to at least 256 MB
We’ve seen this in WooCommerce and OptimizePress, for example.
These warnings are almost always incorrect, and can be ignored. Our PHP settings already use at least 500 MB for PHP 5.6 and later. Software that thinks the limit is 40 MB just has a bug.
In WordPress versions 5.2 and above, you can verify the real amount of memory available by checking WP_MAX_MEMORY_LIMIT in the WordPress "Site Health" section within the administrative dashboard. Click Tools in the left column, then Site Health > Info > WordPress Constants.
Technical details
Some themes and plugins include code that simply checks the value of WP_MEMORY_LIMIT, then displays 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 the /wp-includes/default-constants.php
file to try to raise the PHP memory limit to that amount if (and only if) the current php memory_limit
setting is lower than WP_MEMORY_LIMIT.
If the current PHP memory_limit is already larger than WP_MEMORY_LIMIT (as it is on our systems), the WordPress WP_MEMORY_LIMIT value is not used for anything at all. “Increasing” it does nothing except suppress the incorrect warnings caused by the buggy code.
How can I fix it anyway?
If you want to change this merely to suppress the warnings even though it has no other effect, technically advanced users can add a line like this to the WordPress wp-config.php
file:
define( 'WP_MEMORY_LIMIT', '500M' );
The WordPress “editing wp-config.php” help page has more details.
Copyright © 2000-2024 Tiger Technologies LLC