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

Asked

Viewed 413 times

3

What is the difference between the functions memory_get_usage and memory_get_peak_usage?

The two do the same thing or is there any difference between them?

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 achieved during the entire execution of the script.

  • It’s like I copied the format, but it was like that. hehe +1

4

memory_get_usage: Returns the amount of memory allocated to PHP.

memory_get_peak_usage: Returns the memory peak allocated by PHP.

And the directive :

memory_limit: Directive of php.ini that sets the maximum amount of memory in bytes that a script is allowed to allocate.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.