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

7

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

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

  

Use: 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 Peak is ~ 13kb greater than the Usage . Is it possible to know where in the code the script has reached the peak of memory usage?

    
asked by anonymous 02.06.2015 / 06:31

1 answer

2

This is possible through a profiler.

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

    
02.06.2015 / 12:10