简体   繁体   中英

php memory_get_peak_usage() includes mysql memory usage?

In PHP there is a function memory_get_peak_usage which returns the peak memory used by the current php process.

I want to know if it also includes the memory consumed by mysql queries which were fired by the php process?

I want to know if it also includes the memory consumed by mysql queries which were fired by the php process?

If you fetched results from those queries, and PHP needed to allocate memory as a result of that fetching, then yes, results from a database query will be included in that memory use figure. It will not include memory used by MySQL itself, nor will it include memory used by query results that are not fetched.

This is true of memory_get_peak_usage and memory_get_usage .

The documentation says it does not.

http://php.net/manual/en/function.memory-get-peak-usage.php

Also it does not make sense for this function to include that memory. As this function shows the peak of the script. Also take a look at the user comment which is helpful imo.

http://php.net/manual/en/function.memory-get-peak-usage.php#98734

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