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?
What about saving the value returned by memory_get_peak_usage in a database/file?
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/