Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHP: memory_get_peak_usage(false), when should i use true?

Tags:

php

memory

http://php.net/manual/de/function.memory-get-peak-usage.php point out that by default the value from emalloc() (memory manager written in c++) will be returned.

In what cases should I use true as parameter?

like image 459
DanielaWaranie Avatar asked Jun 01 '11 13:06

DanielaWaranie


1 Answers

As far as my understanding goes here is the answer:

memory_get_peak_usage(true) when you need to find out the WHOLE usage of your app, including all kinds of overheads and etc. It's handy when you want to find out how heavy your app is. true usually rounds up numbers to the bigger size, because you can't just allocate 729 KiloBytes from RAM, your app takes whole 1024 KiloBytes.

memory_get_peak_usage() is handy when you want to find out which 'method' of execution is most lightweight, so you can cram as much actions as possible into the 1024 KiloBytes that are already allocated.

like image 167
Vilius Sutkus '89 Avatar answered Oct 22 '22 09:10

Vilius Sutkus '89