I have used valgrinds massif tool to monitor memory usage in the past.
Does anyone know how to capture memory use of php processes that are spawned on a linux lighttpd server?
I have found that Valgrind can not attach to a prerunning process (and I would not know the PID of the php process before hand anyway)
I only see lighttpd's memory usage, not the PHP processes that are spawned by lighttpd cgi module.
Thanks in advance.
An attacker can view the memory limit set by executing phpinfo() function to see the memory limit and plan an attack according to the value. A server administrator can set memory limit from -1 (No memory allocation) to any size. The memory limit was first introduced as a setting in php.
To get the current memory usage, we can use the memory_get_usage() function, and to get the highest amount of memory used at any point, we can use the memory_get_peak_usage() function.
When I set the PHP memory limit to e.g. 128 MB for each of these daemons, the processes will only get killed once they reach 128 MB according to PHP's own measurements. However, according to ps , the processes will be using around 200 MB each by that time.
PHP has it's own memory testing functions, I don't know if that's any use to you, but if you just want to log it you could use: http://php.net/manual/en/function.memory-get-peak-usage.php
echo "Using ", memory_get_peak_usage(1), " bytes of ram.";
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With