Why WP_MEMORY_LIMIT shouldn’t be set to high values without a valid reason
- WordPress
It might be tempting to increase WP_MEMORY_LIMIT in WordPress without any valid reason.
I’ve seen it set to 1024M for example, or even higher, on some websites. When I asked the site owner of why they put this value, their justification was that the server has enough resources and can afford setting a high value.
A bad practice that might cause trouble along the way.
WP_MEMORY_LIMIT is a limit by script execution and its value should reflect the requirement of the most memory-intensive asset requirement you have.
Here is a scenario to clarify:
If one plugin recommends 256M of RAM and another one recommends 128M of RAM, set the WP_MEMORY_LIMIT to 256M. It should not be the cumulative sum of the recommended values but rather the higher of the two suggestions.
A high value of WP_MEMORY_LIMIT will also limit how many concurrent users you have.
Another example to clarify:
If you have 1024M dedicated to the website, and use a WP_MEMORY_LIMIT of 256M, your server’s capacity will be 4 concurrent users for features using the maximum 256M limit.
When a plugin requires a high amount of WP_MEMORY_LIMIT, it’s advisable to inquire in what circumstances that limit could be reached.