Is it possible to know at what point the script reaches the memory peak?

Asked

Viewed 82 times

7

It is possible to know at what point the script reaches the memory peak?

I have a PHP script that at the end shows this result:

Usage: 380.515625Kb

Peak: 393.5859375Kb

Real: 512kb

Example:

<?php

...

echo PHP_EOL,
    'Uso: ', memory_get_usage() / 1024, 'Kb', PHP_EOL,
    'Pico: ',  memory_get_peak_usage() / 1024, 'Kb',  PHP_EOL,
    'Real: ',  memory_get_usage(true)  / 1024, 'Kb';
?>

The Pico is ~13kb greater than the Use. It is possible to know where part of the code the script reached the peak of memory usage?

1 answer

2

This is possible through a profiler.

Some options are the Xdebug, xhprof and the Blackfire io.. You would need to install on your server the respective extension and analyze the profiler in search of the desired information, in your case where the memory peak occurs.

Browser other questions tagged

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