Pages

Friday, March 14, 2014

How to Check How Much Memory a Process is Consuming in Linux

The pmap command reports the memory map of a process or processes.

OPTIONS

  • -x extended -> Show the extended format.
  • -d device -> Show the device format.
  • -q quiet -> Do not display some header/footer lines.
  • -V show version -> Displays version of program.

Example : we want to check how much memory is consumed by the apache(httpd) process. Run the below commands step by step :

Step:1

To get a pid of httpd process,run below command
  • [root@mail1 ~]# ps -eaf | grep http
root 1759 4493 0 04:02 ? 00:00:00 /usr/sbin/httpd
apache 1760 4493 0 04:02 ? 00:00:25 /usr/sbin/httpd
apache 1761 4493 0 04:02 ? 00:00:23 /usr/sbin/httpd
apache 1762 4493 0 04:02 ? 00:00:21 /usr/sbin/httpd
apache 1763 4493 0 04:02 ? 00:00:18 /usr/sbin/httpd

Step:2

Now run the pmap command against the PID number:
  • [root@mail1 ~]# pmap 1760 | tail
97406000 28K r--s- /usr/lib/gconv/gconv-modules.cache
97463000 16K rw--- [ anon ]
97467000 524288K rw-s- /tmp/apc.tE1RRo (deleted)
b7467000 11096K r---- /usr/local/zend/lib/libicudata.so.38
b7f3d000 4K rw--- /usr/local/zend/lib/libicudata.so.38
b7f3e000 64K rw-s- /dev/zero (deleted)
b7f4e000 504K rw-s- /dev/zero (deleted)
b7fcc000 32K rw--- [ anon ]
bfd74000 144K rwx-- [ stack ]
total 2742152K

The process, which is apache is consuming about 2.7GB of memory

No comments:

Post a Comment