WordPress & PHP memory-related notes
d19dotca last edited by d19dotca
I was recently experimenting a bit with php.ini settings and memory constants in the wp-config.php. Here is what I learned which I had found confusing before, so wanting to share this in case anyone didn't know this already:
When looking at the Tools > Site Health > Info page in WordPress...
PHP memory limitvalue (under Server tab) comes from the
memory_limitset in the php.ini file.
WP_MAX_MEMORY_LIMITvalue (under WordPress Constants tab) also comes from the
memory_limitset in the php.ini file when the
WP_MAX_MEMORY_LIMITisn't also defined in the wp-config.php file. If the
WP_MAX_MEMORY_LIMITis defined in the wp-config.php file, then this overrides the
memory_limitparameter set in the php.ini file.
WP_MEMORY_LIMITvalue (under WordPress Constants tab) comes from the
WP_MEMORY_LIMITdefined in the wp-config.php file (this is hard-coded). If not defined, it defaults to
I would recommend increasing
WP_MEMORY_LIMITcloser to the overall app memory limit by adding something like this to your wp-config.php file:
define( 'WP_MEMORY_LIMIT', '2G' );for a 2 GB memory limit to WordPress for example.
I had found it confusing earlier as to where each parameter was defined and how it was set (and what the defaults are). Hopefully this helps others for the future too.