The WP_MEMORY_LIMIT option allows you to specify the maximum amount of memory that can be consumed by PHP. This setting may be necessary in the event you receive a message such as “Allowed memory size of xxxxxx bytes exhausted”.
This setting increases PHP Memory only for WordPress, not other applications. By default, WordPress will attempt to increase memory allocated to PHP to 40MB (code is at beginning of wp-settings.php), so the setting in wp-config.php should reflect something higher than 40MB.
WordPress will automatically check if PHP has been allocated less memory than the entered value before utilizing this function. For example, if PHP has been allocated 64MB, there is no need to set this value to 64M as WordPress will automatically use all 64MB if need be.
When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.
Note: These are two different settings mentioned above though taken directly from the WordPress codex and obviously not clear about it – we found that one should use them BOTH – for example setting the WordPress memory limit to 1024M one needs to add both:
define('WP_MEMORY_LIMIT', '1024M'); define( 'WP_MAX_MEMORY_LIMIT', '1024M' );
Note 2: The “define” statement goes into your wp-config.php file somewhere just above the /* That’s all, stop editing! Happy blogging. */ statement. Alternatively one may see other define statements there – simply add to the bottom of the list.
That’s it! Make sure to check out our other tutorials for more WordPress tips & tricks.