3

What's the difference beetween

define( 'WP_MEMORY_LIMIT', '96M' ); and define( 'WP_MAX_MEMORY_LIMIT', '256M' );

In my host I have this

define( 'WP_MEMORY_LIMIT', '786M' ); 
define( 'WP_MAX_MEMORY_LIMIT', '512M' );

is this correct, should the WP_MAX_MEMORY_LIMIT be higher ?

3

WordPress tells us:

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".

Or as the PHP docs put it

[A memory limit] helps prevent poorly written scripts for eating up all available memory on a server.

The WordPress Codex also says this about these constants:

This setting [WP_MEMORY_LIMIT] 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 the beginning of /wp-includes/default-constants.php) for single site and 64MB for multisite, so the setting in wp-config.php should reflect something higher than 40MB or 64MB depending on your setup.

And this about the WP_MAX_MEMORY_LIMIT specifically:

Administration tasks require much [more] memory than [a] usual operation. When in the administration area, the memory can be increased or decreased from the WP_MEMORY_LIMIT by defining WP_MAX_MEMORY_LIMIT.

So WP_MEMORY_LIMIT is the limit and WP_MAX_MEMORY_LIMIT, if set, will override the former in the admin.

Now when you ask "is this correct", there is no way for us to tell you definitively.

You may want to raise those limits if your site is growing in visitors and or active plugins but if you are not experiencing any issues I would say you are fine for now.

If you choose to up the limits I have outlined the different methods to increase PHP memory in this answer. Note the last part about your host potentially limiting this value.

  • I note that one of my sites had an issue with 'memory exhausted' during a Postie (plugin) process. Turns out I had WP_MEMORY_LIMIT set to 300M, but no entry for WP_MAX_MEMORY_LIMIT. Since Postie does things at an admin level, I added WP_MAX_MEMORY_LIMIT to 300M in wp-config, and the memory exhaustion error went away. YMMV. – Rick Hellewell Jan 9 '18 at 18:44
0

The WP_MEMORY_LIMIT is the default limit set in the front-end, but it can be raised up to WP_MAX_MEMORY_LIMIT in wp-admin pages, as well as certain other functions such as image manipulation.

In short, you'll want to have the WP_MEMORY_LIMIT set primarily for front-end access, in a way that you won't use up your memory when many concurrent users hit the server. You'd want WP_MAX_MEMORY_LIMIT set higher to allow for admin functions that have heavier requirements, but lower concurrency.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.