Some times its required for us to know what is the RAM utilized by an application. Suppose in your machine Apache service or Mysql service is consuming up all your RAM. So how to check it? Is there any direct command to accomplish this? The answer to this is no. We have to use two commands to accomplish this. Here is the way to see what is the ram utilized by a particular Application.
To see all the process run by a particular application
#pgrep application-name
Example(in Ubuntu)
#pgrep apache
1946
1951
1952
1954
1955
1957
2894
To see all the memory used by a process
#pmap pid-of-that-application
Example :
# pmap 1946
1946: /usr/sbin/apache2 -k start
00110000 28K r-x-- /lib/tls/i686/cmov/librt-2.10.1.so
00117000 4K r---- /lib/tls/i686/cmov/librt-2.10.1.so
00118000 4K rw--- /lib/tls/i686/cmov/librt-2.10.1.so
00119000 8K r-x-- /usr/lib/apache2/modules/mod_auth_basic.so
0011b000 4K r---- /usr/lib/apache2/modules/mod_auth_basic.so
0011c000 4K rw--- /usr/lib/apache2/modules/mod_auth_basic.so
0011d000 8K r-x-- /usr/lib/apache2/modules/mod_authz_groupfile.so
0011f000 4K r---- /usr/lib/apache2/modules/mod_authz_groupfile.so
00120000 4K rw--- /usr/lib/apache2/modules/mod_authz_groupfile.so
00121000 16K r-x-- /usr/lib/apache2/modules/mod_deflate.so
00125000 4K r---- /usr/lib/apache2/modules/mod_deflate.so
00126000 4K rw--- /usr/lib/apache2/modules/mod_deflate.so
00129000 76K r-x-- /lib/tls/i686/cmov/libnsl-2.10.1.so
0013c000 4K r---- /lib/tls/i686/cmov/libnsl-2.10.1.so
0013d000 4K rw--- /lib/tls/i686/cmov/libnsl-2.10.1.so
0013e000 8K rw--- [ anon ]
00140000 32K r-x-- /usr/lib/apache2/modules/mod_autoindex.so
00148000 4K r---- /usr/lib/apache2/modules/mod_autoindex.so
00149000 4K rw--- /usr/lib/apache2/modules/mod_autoindex.so
0014a000 80K r-x-- /lib/libz.so.1.2.3.3
0015e000 4K r---- /lib/libz.so.1.2.3.3
0015f000 4K rw--- /lib/libz.so.1.2.3.3
00160000 8K r-x-- /lib/libcom_err.so.2.1
00162000 4K r---- /lib/libcom_err.so.2.1
00163000 4K rw--- /lib/libcom_err.so.2.1
00164000 8K r-x-- /lib/libkeyutils-1.2.so
00166000 4K r---- /lib/libkeyutils-1.2.so
00167000 4K rw--- /lib/libkeyutils-1.2.so
00168000 24K r-x-- /usr/lib/php5/20060613+lfs/pdo_mysql.so
0016e000 4K r---- /usr/lib/php5/20060613+lfs/pdo_mysql.so
0016f000 4K rw--- /usr/lib/php5/20060613+lfs/pdo_mysql.so
00171000 24K r-x-- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
00177000 4K r---- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
00178000 4K rw--- /lib/tls/i686/cmov/libnss_compat-2.10.1.so
00179000 36K r-x-- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
00182000 4K r---- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
00183000 4K rw--- /lib/tls/i686/cmov/libnss_nis-2.10.1.so
00184000 144K r-x-- /lib/tls/i686/cmov/libm-2.10.1.so
001a8000 4K r---- /lib/tls/i686/cmov/libm-2.10.1.so
001a9000 4K rw--- /lib/tls/i686/cmov/libm-2.10.1.so
001aa000 40K r-x-- /usr/lib/php5/20060613+lfs/mysql.so
001b4000 4K r---- /usr/lib/php5/20060613+lfs/mysql.so
001b5000 4K rw--- /usr/lib/php5/20060613+lfs/mysql.so
001bf000 28K r-x-- /usr/lib/apache2/modules/mod_negotiation.so
001c6000 4K r---- /usr/lib/apache2/modules/mod_negotiation.so
001c7000 4K rw--- /usr/lib/apache2/modules/mod_negotiation.so
001c8000 92K r-x-- /usr/lib/php5/20060613+lfs/mysqli.so
001df000 4K r---- /usr/lib/php5/20060613+lfs/mysqli.so
001e0000 8K rw--- /usr/lib/php5/20060613+lfs/mysqli.so
001e4000 4K r-x-- [ anon ]
001f0000 188K r-x-- /lib/libpcre.so.3.12.1
0021f000 4K r---- /lib/libpcre.so.3.12.1
00220000 4K rw--- /lib/libpcre.so.3.12.1
00221000 76K r-x-- /usr/lib/php5/20060613+lfs/pdo.so
00234000 4K r---- /usr/lib/php5/20060613+lfs/pdo.so
00235000 8K rw--- /usr/lib/php5/20060613+lfs/pdo.so
00241000 4K r-x-- /usr/lib/apache2/modules/mod_dir.so
00242000 4K ----- /usr/lib/apache2/modules/mod_dir.so
00243000 4K r---- /usr/lib/apache2/modules/mod_dir.so
00244000 4K rw--- /usr/lib/apache2/modules/mod_dir.so
00246000 64K r-x-- /lib/tls/i686/cmov/libresolv-2.10.1.so
00256000 4K r---- /lib/tls/i686/cmov/libresolv-2.10.1.so
00257000 4K rw--- /lib/tls/i686/cmov/libresolv-2.10.1.so
00258000 8K rw--- [ anon ]
00260000 36K r-x-- /lib/tls/i686/cmov/libcrypt-2.10.1.so
00269000 4K r---- /lib/tls/i686/cmov/libcrypt-2.10.1.so
0026a000 4K rw--- /lib/tls/i686/cmov/libcrypt-2.10.1.so
0026b000 156K rw--- [ anon ]
00292000 112K r-x-- /lib/libgcc_s.so.1
002ae000 4K r---- /lib/libgcc_s.so.1
002af000 4K rw--- /lib/libgcc_s.so.1
002b9000 12K r-x-- /lib/libuuid.so.1.3.0
002bc000 4K r---- /lib/libuuid.so.1.3.0
002bd000 4K rw--- /lib/libuuid.so.1.3.0
002be000 260K r-x-- /lib/i686/cmov/libssl.so.0.9.8
002ff000 4K ----- /lib/i686/cmov/libssl.so.0.9.8
00300000 4K r---- /lib/i686/cmov/libssl.so.0.9.8
00301000 12K rw--- /lib/i686/cmov/libssl.so.0.9.8
00304000 152K r-x-- /usr/lib/libk5crypto.so.3.1
0032a000 4K ----- /usr/lib/libk5crypto.so.3.1
0032b000 4K r---- /usr/lib/libk5crypto.so.3.1
0032c000 4K rw--- /usr/lib/libk5crypto.so.3.1
00349000 144K r-x-- /lib/libexpat.so.1.5.2
0036d000 8K r---- /lib/libexpat.so.1.5.2
0036f000 4K rw--- /lib/libexpat.so.1.5.2
00385000 4K r-x-- /usr/lib/apache2/modules/mod_authz_user.so
00386000 4K r---- /usr/lib/apache2/modules/mod_authz_user.so
00387000 4K rw--- /usr/lib/apache2/modules/mod_authz_user.so
003ec000 160K r-x-- /usr/lib/libgssapi_krb5.so.2.2
00414000 4K r---- /usr/lib/libgssapi_krb5.so.2.2
00415000 4K rw--- /usr/lib/libgssapi_krb5.so.2.2
00416000 636K r-x-- /usr/lib/libkrb5.so.3.3
004b5000 4K ----- /usr/lib/libkrb5.so.3.3
004b6000 20K r---- /usr/lib/libkrb5.so.3.3
004bb000 4K rw--- /usr/lib/libkrb5.so.3.3
004e3000 8K r-x-- /usr/lib/apache2/modules/mod_alias.so
004e5000 4K ----- /usr/lib/apache2/modules/mod_alias.so
004e6000 4K r---- /usr/lib/apache2/modules/mod_alias.so
004e7000 4K rw--- /usr/lib/apache2/modules/mod_alias.so
00501000 8K r-x-- /usr/lib/apache2/modules/mod_setenvif.so
00503000 4K r---- /usr/lib/apache2/modules/mod_setenvif.so
00504000 4K rw--- /usr/lib/apache2/modules/mod_setenvif.so
0060f000 8K r-x-- /usr/lib/apache2/modules/mod_authz_host.so
00611000 4K r---- /usr/lib/apache2/modules/mod_authz_host.so
00612000 4K rw--- /usr/lib/apache2/modules/mod_authz_host.so
006f6000 4K r-x-- /usr/lib/apache2/modules/mod_env.so
006f7000 4K r---- /usr/lib/apache2/modules/mod_env.so
006f8000 4K rw--- /usr/lib/apache2/modules/mod_env.so
006f9000 1428K r-x-- /usr/lib/libdb-4.7.so
0085e000 8K r---- /usr/lib/libdb-4.7.so
00860000 4K rw--- /usr/lib/libdb-4.7.so
00907000 20K r-x-- /usr/lib/apache2/modules/mod_cgi.so
0090c000 4K r---- /usr/lib/apache2/modules/mod_cgi.so
0090d000 4K rw--- /usr/lib/apache2/modules/mod_cgi.so
00950000 4K r-x-- /usr/lib/apache2/modules/mod_authz_default.so
00951000 4K r---- /usr/lib/apache2/modules/mod_authz_default.so
00952000 4K rw--- /usr/lib/apache2/modules/mod_authz_default.so
0099e000 4K r-x-- /usr/lib/apache2/modules/mod_authn_file.so
0099f000 4K r---- /usr/lib/apache2/modules/mod_authn_file.so
009a0000 4K rw--- /usr/lib/apache2/modules/mod_authn_file.so
00a13000 372K r-x-- /usr/lib/apache2/mpm-prefork/apache2
00a71000 8K r---- /usr/lib/apache2/mpm-prefork/apache2
00a73000 8K rw--- /usr/lib/apache2/mpm-prefork/apache2
00a75000 12K rw--- [ anon ]
00ad5000 24K r-x-- /usr/lib/libkrb5support.so.0.1
00adb000 4K r---- /usr/lib/libkrb5support.so.0.1
00adc000 4K rw--- /usr/lib/libkrb5support.so.0.1
00b28000 132K r-x-- /usr/lib/libaprutil-1.so.0.3.9
00b49000 4K r---- /usr/lib/libaprutil-1.so.0.3.9
00b4a000 4K rw--- /usr/lib/libaprutil-1.so.0.3.9
00b66000 64K r-x-- /lib/libbz2.so.1.0.4
00b76000 4K r---- /lib/libbz2.so.1.0.4
00b77000 4K rw--- /lib/libbz2.so.1.0.4
00b90000 16K r-x-- /usr/lib/apache2/modules/mod_status.so
00b94000 4K r---- /usr/lib/apache2/modules/mod_status.so
00b95000 4K rw--- /usr/lib/apache2/modules/mod_status.so
00ba6000 164K r-x-- /usr/lib/libapr-1.so.0.3.8
00bcf000 4K r---- /usr/lib/libapr-1.so.0.3.8
00bd0000 4K rw--- /usr/lib/libapr-1.so.0.3.8
00bf5000 12K r-x-- /usr/lib/apache2/modules/mod_mime.so
00bf8000 4K r---- /usr/lib/apache2/modules/mod_mime.so
00bf9000 4K rw--- /usr/lib/apache2/modules/mod_mime.so
00c7e000 40K r-x-- /lib/tls/i686/cmov/libnss_files-2.10.1.so
00c88000 4K r---- /lib/tls/i686/cmov/libnss_files-2.10.1.so
00c89000 4K rw--- /lib/tls/i686/cmov/libnss_files-2.10.1.so
00ce9000 1272K r-x-- /lib/tls/i686/cmov/libc-2.10.1.so
00e27000 8K r---- /lib/tls/i686/cmov/libc-2.10.1.so
00e29000 4K rw--- /lib/tls/i686/cmov/libc-2.10.1.so
00e2a000 12K rw--- [ anon ]
00e67000 84K r-x-- /lib/tls/i686/cmov/libpthread-2.10.1.so
00e7c000 4K r---- /lib/tls/i686/cmov/libpthread-2.10.1.so
00e7d000 4K rw--- /lib/tls/i686/cmov/libpthread-2.10.1.so
00e7e000 8K rw--- [ anon ]
00f69000 108K r-x-- /lib/ld-2.10.1.so
00f84000 4K r---- /lib/ld-2.10.1.so
00f85000 4K rw--- /lib/ld-2.10.1.so
00f9d000 8K r-x-- /lib/tls/i686/cmov/libdl-2.10.1.so
00f9f000 4K r---- /lib/tls/i686/cmov/libdl-2.10.1.so
00fa0000 4K rw--- /lib/tls/i686/cmov/libdl-2.10.1.so
00fa1000 5036K r-x-- /usr/lib/apache2/modules/libphp5.so
0148c000 4K ----- /usr/lib/apache2/modules/libphp5.so
0148d000 68K r---- /usr/lib/apache2/modules/libphp5.so
0149e000 148K rw--- /usr/lib/apache2/modules/libphp5.so
014c3000 20K rw--- [ anon ]
01cc1000 1204K r-x-- /lib/i686/cmov/libcrypto.so.0.9.8
01dee000 32K r---- /lib/i686/cmov/libcrypto.so.0.9.8
01df6000 52K rw--- /lib/i686/cmov/libcrypto.so.0.9.8
01e03000 16K rw--- [ anon ]
03087000 1716K r-x-- /usr/lib/libmysqlclient_r.so.16.0.0
03234000 12K r---- /usr/lib/libmysqlclient_r.so.16.0.0
03237000 276K rw--- /usr/lib/libmysqlclient_r.so.16.0.0
0327c000 4K rw--- [ anon ]
06147000 1160K r-x-- /usr/lib/libxml2.so.2.7.5
06269000 4K ----- /usr/lib/libxml2.so.2.7.5
0626a000 16K r---- /usr/lib/libxml2.so.2.7.5
0626e000 4K rw--- /usr/lib/libxml2.so.2.7.5
0626f000 4K rw--- [ anon ]
21436000 2820K rw--- [ anon ]
b6d8a000 4K ----- [ anon ]
b6d8b000 10240K rw--- [ anon ]
b77cc000 16K rw--- [ anon ]
b77d0000 64K rw-s- /dev/zero (deleted)
b77e0000 8K rw--- [ anon ]
bfc89000 84K rw--- [ stack ]
total 29964K
So you have to run this command on all the process of apache application. If you see the last line its showing total RAM utilized by this PID. Which is ~30MB. Which is nothing but total RAM used by this PID
Suppose if you want to see all the memory(RAM), files opend by apache use below command
#pmap `pgrep apache`
If you execute above command it will give pages and pages of information which you donot require, to get answer in presized way. Just grep last line with "total".
Example :
# pmap `pgrep apache` | grep total
total 29964K
total 29964K
total 29964K
total 29964K
total 29964K
total 29964K
total 29964K
Please share your thoughts if you have more better options to check RAM utilization by an application:-)
Hot To See Memory(RAM) Used By An Application Or Service?
0 comments 5/06/2010 11:34:00 AM Posted by Surendra Kumar AnneLabels: How-To's, Process-Mgmt
Subscribe to:
Posts (Atom)