Does PHP memory_limit provide pre-allocation of memory for PHP?

Some pages on our site are affected by the PHP memory limit, which is currently set to 128 MB. When requesting a memory limit of up to 256 MB, we were told by the engineer of our hosting company that:

On our server, "the average request requires less than 64 MB of RAM"

and

"a memory offset of up to 256 MB essentially creates an average allocation of 192 MB of memory that will not be used for most requests"

Is it correct that the amount of memory_limit is actually pre-allocated and will be lost at 192 MB for most of our requests?

Thank!

+4
source share
4
+6

, . max, script. . php memory_get_usage.

+3

. memory_limit.

. : PHP?

, , , 256M , 192M. , 64M.

+2
source

The dot on the PHP memory limit “prevents poorly written scripts to eat up all available memory on the server” rather than “preallocating the amount of memory”.

For example, from PHP5.6 source This is just a hard cap that can be used if necessary - or other words "The maximum amount of memory a script can consume."

zend_mm_safe_error(heap, "Allowed memory size of %ld bytes exhausted (tried to allocate %ld bytes)", heap->limit, size);

REF: http://jpauli.imtqy.com/2014/07/02/php-memory.html

+1
source

Source: https://habr.com/ru/post/1629500/


All Articles