What is the difference between "memory_get_usage" and "memory_get_peak_usage"?

3

What is the difference between the functions memory_get_usage and memory_get_peak_usage ?

Do the two do the same or are there any differences between them?

    
asked by anonymous 18.01.2017 / 18:54

2 answers

8

memory_get_usage is the amount of memory being used at that time.

memory_get_peak_usage is the maximum amount of memory reached during the entire execution of the script.

    
18.01.2017 / 18:59
4

memory_get_usage : Returns the amount of memory allocated for PHP.

memory_get_peak_usage : Returns the peak memory allocated by PHP.

And the directive:

memory_limit : php.ini directive that defines the amount maximum byte memory that a script is allowed to allocate.

    
18.01.2017 / 19:03