[wp-trac] [WordPress Trac] #32075: Only set WP_MAX_MEMORY_LIMIT by default when its greater than memory_limit

WordPress Trac noreply at wordpress.org
Sun Apr 10 08:25:04 UTC 2016


#32075: Only set WP_MAX_MEMORY_LIMIT by default when its greater than memory_limit
------------------------------------+-----------------------------
 Reporter:  danielbachhuber         |       Owner:
     Type:  defect (bug)            |      Status:  new
 Priority:  normal                  |   Milestone:  Future Release
Component:  Bootstrap/Load          |     Version:  3.2
 Severity:  normal                  |  Resolution:
 Keywords:  has-patch dev-feedback  |     Focuses:
------------------------------------+-----------------------------

Comment (by mensmaximus):

 Replying to [comment:18 jrf]:
 > > Imho the WP_MAX_MEMORY_LIMIT constant should never report a larger
 amount of memory than the maximum allocatable memory.
 >
 > AFAIK there is no reliable way to find out the maximum allocatable
 memory on the server, so there is no way I can think of to take that into
 account when setting the constant, quite apart from the fact that the
 constant can be defined in `wp-config.php` outside of our control.

 I should have written "allocated" instead of "allocatable". As for now
 WP_MAX_MEMORY_LIMIT is simply set to 256M by default. There is no
 verification whether it is really possible to set this value. Plugins like
 WooCommerce "report" this value in the backend on a status page and a user
 is told "the memory is ok".

 You are absolutely correct a developer should never ever rely on any
 constant. But as you can see it is done. Not in the means of a
 "dependency" but in the means of reported "unchecked and unfiltered".
 Reporting something to the user that isn't true and may complicate the
 troubleshooting is simply spoken wrong.

 Imho you have to get the allocated memory first, than try to increase it
 to 256M. If the return value is true you can define WP_MAX_MEMORY_LIMIT to
 256M otherwise you set it to the currently allocated memory.

 In today's hosting environments you will find PHP-FPM very often and there
 it is easy to restrict the memory allocation by defining it with
 php_admin_value[memory_limit] instead of php_value[memory_limit].

--
Ticket URL: <https://core.trac.wordpress.org/ticket/32075#comment:19>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list