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 it
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?