简体   繁体   中英

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM