• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Profiler Memory Usage is misleading

#1
[eluser]dmorin[/eluser]
The profiler uses mem_get_usage to report memory usage. This function gets the memory usage at the current moment and since the profiler is included at the end of script execution, the number it provides can be very misleading depending on what has been unset, etc.

Using memory_get_peak_usage gives a more accurate figure especially considering this is the kind of number you need to know when running into out of memory errors. Since this is only available in 5.2 and higher it should be in addition to the current function.

~line 346 in Profiler.php could become

Code:
$output .= "<div style='color:#000;font-weight:normal;padding:4px 0 4px 0'>".number_format($usage)." bytes";
if (function_exists('memory_get_peak_usage')) {
    $output .= " ( " . number_format(memory_get_peak_usage()) . " peak bytes )";
}
$output .= "</div>";


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.