Why is the result of php memory_get_peak_usage very different from the size of the memory, which is shown as dedicated for processing when using the "top" or "ps" commands on Linux?
I installed 2 Mb memory_limit in php.ini My single line php script with
echo memory_get_peak_usage(true);
says it uses 786432 bytes (768 Kb)
If I try to ask the system about the current php process
echo shell_exec('ps -p '.getmypid().' -Fl');
it gives me
FS UID PID PPID C PRI NI ADDR SZ WCHAN RSS PSR STIME TTY TIME CMD 5 S www-data 14599 14593 0 80 0 - 51322 pipe_w 6976 2 18:53 ? 00:00:00 php-fpm: pool www
RSS param is 6976, so memory usage is 6976 * 4096 = 28573696 = ~ 28 MB
Where does this 28 MB come from and is there a way to reduce the memory size used by the php-fpm process?
source share