I'm seeing my long running php processes utilize significant amounts of memory, and it grows very quickly. After about a day, I saw the following:
# pmap <pid>
000000000091c000 588K rw--- /usr/bin/php
00000000009af000 108K rw--- [ anon ]
00000000013ab000 256948K rw--- [ anon ]
00007f9ed0000000 132K rw--- [ anon ]
...
00007f9edcaa6000 8K rw--- /usr/lib64/php/modules/curl.so
00007f9edcaa8000 103580K r---- /usr/lib/locale/locale-archive
...
total 629312K
# cat /proc/<pid>/status
Name: php
State: S (sleeping)
...
VmHWM: 268920 kB
VmRSS: 268920 kB
VmData: 334368 kB
VmStk: 136 kB
VmExe: 3188 kB
VmLib: 22752 kB
VmPTE: 912 kB
VmSwap: 0 kB
Threads: 1
...
Mems_allowed: 00000000,00000001
Mems_allowed_list: 0
voluntary_ctxt_switches: 11902137
ps aux
0.5 4.3 694124 333864 ? S Jan21 8:11 php
top
PR NI VIRT RES SHR S %CPU %MEM TIME+ CODE DATA COMMAND
20 0 677m 326m 9100 S 0.0 4.4 8:11.56 3188 390m php
but, memory_get_usage(true) consistently returns:
1835008
There seems to be a memory leak, but how can I diagnose the cause, and reduce it? I've tried to utilize tools such as this, but similar to memory_get_usage
, it doesn't notice any additional memory usage
I've also tried: # strace -p -e trace=memory but all I see are brk() calls, like so:
brk(0) = 0x14f6f000
brk(0x14f90000) = 0x14f90000
I'm on version 5.4.27:
# php --version
PHP 5.4.27 (cli) (built: Apr 23 2014 23:34:13)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies