Does memory memory_get_peak_usage () return the memory of all php or just the current execution?

Let's say I call memory_get_peak_usage(true) and returns 2.5MB .

  • Does this mean that all php (all clients) is causing this peak?

  • Or does this mean that if I have 100 clients at the same time, the peak may be 250 MB?

+2
function php memory
Aug 29 '11 at 18:10
source share
1 answer

It returns maximum usage only for the current request.

From the doc :

Returns the memory peak in bytes that has been allocated for your PHP script.




To remove any uncertainties from documents:

memory_get_peak_usage () calls the internal function zend_memory_peak_usage () , which returns AG(mm_heap)->peak .

AG(mm_heap)->peak reset to 0 in zend_mm_shutdown () , which is called in php_request_shutdown () at the end of each request.

Thus, this is the maximum memory usage for the current request.

+6
Aug 29 '11 at 18:12
source share



All Articles