WordPress & PHP memory-related notes
WordPress (Developer)
1
Posts
1
Posters
391
Views
2
Watching
-
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...
- The
PHP memory limitvalue (under Server tab) comes from thememory_limitset in the php.ini file. - The
WP_MAX_MEMORY_LIMITvalue (under WordPress Constants tab) also comes from thememory_limitset in the php.ini file when theWP_MAX_MEMORY_LIMITisn't also defined in the wp-config.php file. If theWP_MAX_MEMORY_LIMITis defined in the wp-config.php file, then this overrides thememory_limitparameter set in the php.ini file. - The
WP_MEMORY_LIMITvalue (under WordPress Constants tab) comes from theWP_MEMORY_LIMITdefined in the wp-config.php file (this is hard-coded). If not defined, it defaults to40M.
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.
- The