What’s the difference between WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT?

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.

Leave a Comment