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

前端 未结 1 806
难免孤独
难免孤独 2021-01-18 10:08

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.

1条回答
  •  一向
    一向 (楼主)
    2021-01-18 10:36

    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.

    0 讨论(0)
提交回复
热议问题