I think I may have a memory leak in my LAMP application (memory gets used up, swap starts getting used, etc.). If I could see how much memory the various processes are using
You can use pmap
+ awk
.
Most likely, we're interested in the RSS
memory which is the 3rd column in the last line of the example pmap
output below (82564).
$ pmap -x
Address Kbytes RSS Dirty Mode Mapping
....
00007f9caf3e7000 4 4 4 r---- ld-2.17.so
00007f9caf3e8000 8 8 8 rw--- ld-2.17.so
00007fffe8931000 132 12 12 rw--- [ stack ]
00007fffe89fe000 8 8 0 r-x-- [ anon ]
ffffffffff600000 4 0 0 r-x-- [ anon ]
---------------- ------ ------ ------
total kB 688584 82564 9592
Awk is then used to extract that value.
$ pmap -x | awk '/total/ { print $4 "K" }'
The pmap
values are in kilobytes. If we wanted it in megabytes, we could do something like this.
$ pmap -x | awk '/total/ { print $4 / 1024 "M" }'