Home  >  Article  >  Backend Development  >  How to get the total memory used by a php program from the beginning to the end of running

How to get the total memory used by a php program from the beginning to the end of running

WBOY
WBOYOriginal
2016-10-19 10:40:511196browse

How to get the total memory used by a php program from the beginning to the end of it

Reply content:

How to get the total memory used by a php program from the beginning to the end of it

memory_get_usage This function can get the memory currently used by PHP.
memory_get_peak_usage This function can get the memory peak applied by PHP during previous processing.

Record the current memory usage through memory_get_usage when the program starts running,
Get the peak memory usage through memory_get_peak_usage at the end of the program,
The only difference between the two is the maximum memory applied during this process.

This should be what you call "total memory used", right?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn