Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
mem_usage vs memory_get_usage
  • Hi there, I am have test a memory usage in fuelPHP after get a great {mem_usage} on my fuel project. in file index.php fuelphp {mem_usage}
    $response->body(str_replace(array('{exec_time}', '{mem_usage}'), array(round($bm[0], 4), round($bm[1] / pow(1024, 2), 3)), $response->body()));
    

    and this code is pure PHP memory_get_usage()
    round((memory_get_usage()/(1024*1024)),3);
    

    from this code will show memory usage in xxx.xxx MB. I am put both of code into webpage of my project this what i am got:
    - {mem_usage} show me 0.233 Mb
    - PHP memory_get_usage() show me 0.676 Mb

    So now i am trying to convert from MB to Kb. in file index.php fuelphp {mem_usage}
    $response->body(str_replace(array('{exec_time}', '{mem_usage}'), array(round($bm[0], 4), round($bm[1] / pow(1024, 1), 3)), $response->body()));
    

    and this code is pure PHP memory_get_usage()
    round((memory_get_usage()/(1024)),3);
    

    this is result:
    - {mem_usage} show me 238.945 kb
    - PHP memory_get_usage() show me 692.602 kb anyone please tell me about this, because fuelphp show all great memory usage.. my self not need faster or small memory usage.. just need correct detail on my website. I am not been test about Page rendered yet will test it later.
  • The way Fuel does it, is the most reliable, as the peak memory is requested, and it is requested after all processing has been completed. If you retrieve memory usage in your code, it will most likely be lower that what it actually is. memory_get_usage() is useless, it doesn't tell you anything.
  • I found that profiling in fuelphp are using memory_get_usage() too. there should be fixed to use memory_get_peak_usage() as default of fuel {mem_usage} because it's show different result that can make confuse
  • memory_get_usage() returns the memory usage at that precise moment. Fuel uses memory_get_peak_usage(), which is the maximum amount of memory used when processing the request, and is more accurate, as this is what could cause an error if you application peaks above the maximum amount of memory configured in your php.ini. See http://www.ibm.com/developerworks/opensource/library/os-php-v521/ for a good explanation.
  • Thank you to answer WanWizard, seem it right memory_get_peak_usage() & memory_get_usage() is different that my result is different too.. keep to use fuel mem_usage in better way ;-)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion