tl;dr: Manually set value or the default values of WP_MEMORY_LIMIT/WP_MAX_MEMORY_LIMIT have no effect if WP_MEMORY_LIMIT/WP_MAX_MEMORY_LIMIT less than or equal to the memory limit of PHP (hereinafter memory_limit called) is. They are used to set too low values of memory_limit dynamically to a recommended minimum.
- The constant
WP_MEMORY_LIMITcan optionally inwp-config.phpwithdefine('WP_MEMORY_LIMIT', 'XXXM');be set. - The constant
WP_MAX_MEMORY_LIMITcan optionally inwp-config.phpwithdefine('WP_MAX_MEMORY_LIMIT', 'XXXM');be set. - Is
WP_MEMORY_LIMITnot set, applies to its default value:memory_limit, provided the value ofmemory_limitcannot be changed dynamically,- 64 MB if it is a multisite,
- 40MB otherwise.
- Is
WP_MAX_MEMORY_LIMITnot set, applies to its default value:memory_limit, provided the value ofmemory_limitis not dynamically changeable or if it is unbounded (-1) or greater than or equal to 256 MB,- 256 MB otherwise.
- The default values have been raised again and again in the past.
WP_MEMORY_LIMITchanged everywhere using the function ini_set() dynamicmemory_limit, ifWP_MEMORY_LIMITlarger than the current onememory_limitor whenWP_MEMORY_LIMITis unlimited (-1).WP_MAX_MEMORY_LIMITchanged in the backend (more precisely: whenever the function wp_raise_memory_limit() called in different contexts [admin, image]) using the function ini_set() dynamicmemory_limit, ifWP_MAX_MEMORY_LIMITlarger than the current onememory_limitor whenWP_MAX_MEMORY_LIMITis unlimited (-1).- The logic of
WP_MAX_MEMORY_LIMITruns after the logic ofWP_MEMORY_LIMIT, so thatWP_MEMORY_LIMITin the frontend andWP_MAX_MEMORY_LIMITtakes effect in the backend. - Much of the logic described above is in function wp_initial_constants() (
/wp-includes/default-constants.php) as in wp_raise_memory_limit() (/wp-includes/functions.php) instead of. - The value
memory_limit = XXXMinphp.iniAre definedmemory_limit(after restarting the web service). - The value
php_value memory_limit XXXMin.htaccessAre definedmemory_limitfor all PHP files in the folder or its subfolder in which the.htaccesslocated. - The web server can prevent the value of the memory limit from being changed with ini_set() or from exceeding a specified value (see php_admin_value ).
memory_limitapplies per process: An increase ofmemory_limitcan cause the number of parallel PHP requests to decrease. The value should therefore be chosen carefully (256 MB, in exceptional cases 512 MB).- In the WordPress backend under Tools > Website State, the values of
memory_limit(Section: Server), as well as fromWP_MEMORY_LIMITandWP_MAX_MEMORY_LIMIT(section WordPress constants) can be read out.