Measure maximum PHP memory usage

╄→尐↘猪︶ㄣ 提交于 2020-02-01 06:20:05

问题


Setting php_value memory_limit always involves a bit of guesswork and I myself tend to use higher than necessary values just to make sure that the odd memory hungry call does not result in a fatal error.

Still, I am looking for a shell script that would behave kind of like htop or top but instead of showing the current values it would remember only the maximum memory consumed by a PHP script and retain it. Such value, over a few days, would be a very valuable indicator of what php_value memory_limit should be set to. Does something like that exist?


回答1:


What about saving the value returned by memory_get_peak_usage in a database/file?




回答2:


I guess this is very difficult to employ in a useful manner, because it depends on the structure and amount of data that you're processing.

Say you're measuring this week and have about 100 abstract rows of data. You settle on a number. In two months time, your site/app goes viral and you have 10000 abstract rows of data to process.

So what I am saying is this: while your measured value might be appropriate for today, it might not be for tomorrow if the data you process today is different from tomorrow's.


This link explaining php's memory manager could be of use: http://www.ibm.com/developerworks/opensource/library/os-php-v521/



来源:https://stackoverflow.com/questions/7891614/measure-maximum-php-memory-usage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!