Track memory usage of a method

后端 未结 6 2154
[愿得一人]
[愿得一人] 2021-02-20 11:58

I have yet to find an elegant solution for this. I have a class with a method I want to track the memory usage of without modifying the function:

class Example
{         


        
6条回答
  •  情书的邮戳
    2021-02-20 12:33

    The memory is released when you are returning from the function.

    You might add the $s = memory_get_usage(); ... echo memory_get_usage() - $s; block inside of the function. This way, the memory used will not be released.

提交回复
热议问题