Opened 3 years ago
Last modified 3 months ago
#54117 new enhancement
Changing memory limit descriptions
Reported by: | fyremoon | Owned by: | |
---|---|---|---|
Milestone: | Awaiting Review | Priority: | normal |
Severity: | minor | Version: | 5.8.1 |
Component: | Bootstrap/Load | Keywords: | needs-patch |
Focuses: | docs | Cc: |
Description
Hi,
A couple of things that stand out, WP_MAX_MEMORY_LIMIT is for the admin side of the site and WP_MEMORY_LIMIT is for the visitor side. If these were updated in the next version to more friendly names like WP_VISITOR_MEMORY_LIMIT and WP_ADMIN_MEMORY_LIMIT, it would be easier to set up these limits.
How is the memory limit decided for WordPress? I've overridden the defaults since my server has 1GB max memory for PHP, so I've set them to 512 and 1024 respectively but is there a reason why the memory limits are set to arbitrary figures and not a percentage of the limit?
Change History (3)
#2
@
10 months ago
- Component changed from General to Bootstrap/Load
- Focuses docs added
- Keywords needs-patch added
#3
@
3 months ago
is there a reason why the memory limits are set to arbitrary figures and not a percentage of the limit?
In general, using megabytes as values is a widely adopted standard. This practice makes it easier to understand and manage resource limits effectively. WordPress follows this approach as PHP configurations and server settings are also defined in megabytes, ensuring compatibility and avoiding potential errors.
Setting resource limits as percentages can lead to inconsistencies. For example, some hosting providers might advertise that they allocate a certain percentage for WP_MEMORY_LIMIT. However, if this percentage translates to only 40MB, it would be insufficient for many WordPress sites and fall below the minimum requirements for many plugins and themes. Thus, using fixed megabyte values ensures that resource limits are clear, predictable, and adequate for optimal performance.
Thanks for this, @fyremoon, and welcome to Trac! Apologies that it took so long to receive a response.
I'll start by saying the likelihood that the names of these constants are changed is almost 0. This is because of the very high amount of usage within plugins. These two links also only show plugins referencing these constants. It's impossible to know how many people are assigning a custom value to these within
wp-config.php
files or by other means.That said, I think there are some opportunities to provide better inline documentation around how memory limits are set, and how they can be altered or controlled. On first look, it seems that
wp_raise_memory_limit()
and the filters within that function have some good details. However, where the constants are initially assigned value there is no documentation.