Does memory_get_peak_usage() returns memory of the whole php or just the current execution?
Let's say i call memory_get_peak_usage(true)
and it returns 2.5MB
.
Does it means that the whole php开发者_运维技巧 (all clients) is causing that peak?
Or does it means that if I have 100 clients acessing the same time, the peak could be 250MB?
It returns the peak usage for the current request only.
From the doc:
Returns the peak of memory, in bytes, that's been allocated to your PHP script.
To remove any ambiguities from the docs:
memory_get_peak_usage() calls the internal zend_memory_peak_usage() function, which returns AG(mm_heap)->peak
.
AG(mm_heap)->peak
is reset to 0
in zend_mm_shutdown(), which is called in php_request_shutdown() at the end of each request.
So it's the peak memory usage for the current request only.
精彩评论