WordPress & PHP memory-related notes
-
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
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login