I was trying to measure how much memory an application is using in the current moment.
So here we go, free -k -t
:
[user@server ~]$ free -k -t
total used free shared buffers cached
Mem: 1026076 581880 444196 0 158656 269704
-/+ buffers/cache: 153520 872556
Swap: 0 0 0
Total: 1026076 581880 444196
Then pmap -x PID wanted to verify:
[user@server ~]$ pmap -x 18503
18503: /usr/bin/java -jar /home/user/app.jar mycfg.cfg
Address Kbytes RSS Dirty Mode Mapping
0000000040000000 36 36 0 r-x-- java
0000000040108000 8 8 8 rwx-- java
00000000403d9000 4 0 0 ----- [ anon ]
00000000403da000 1024 12 12 rwx-- [ anon ]
000000004055b000 12 0 0 ----- [ anon ]
000000004055e000 1016 72 72 rwx-- [ anon ]
000000004065c000 12 0 0 ----- [ anon ]
000000004065f000 1016 72 72 rwx-- [ anon ]
00000000407ad000 12 0 0 ----- [ anon ]
00000000407b0000 1016 32 32 rwx-- [ anon ]
00000000408ae000 12 0 0 ----- [ anon ]
00000000408b1000 1016 36 36 rwx-- [ anon ]
00000000409cc000 12 0 0 ----- [ anon ]
00000000409cf000 1016 100 100 rwx-- [ anon ]
0000000040acd000 12 0 0 ----- [ anon ]
0000000040ad0000 1016 72 72 rwx-- [ anon ]
0000000040bce000 12 0 0 ----- [ anon ]
0000000040bd1000 1016 40 40 rwx-- [ anon ]
0000000040ccf000 12 0 0 ----- [ anon ]
0000000040cd2000 1016 36 36 rwx-- [ anon ]
0000000040e8a000 12 0 0 ----- [ anon ]
0000000040e8d000 1016 68 68 rwx-- [ anon ]
0000000040f8b000 12 0 0 ----- [ anon ]
0000000040f8e000 1016 68 68 rwx-- [ anon ]
00000000410dd000 12 0 0 ----- [ anon ]
00000000410e0000 1016 68 68 rwx-- [ anon ]
00000000411de000 12 0 0 ----- [ anon ]
00000000411e1000 1016 36 36 rwx-- [ anon ]
00000000412df000 12 0 0 ----- [ anon ]
00000000412e2000 1016 40 40 rwx-- [ anon ]
000000004144a000 12 0 0 ----- [ anon ]
000000004144d000 1016 8 8 rwx-- [ anon ]
000000004154b000 12 0 0 ----- [ anon ]
000000004154e000 1016 48 48 rwx-- [ anon ]
00000000416a7000 12 0 0 ----- [ anon ]
00000000416aa000 1016 36 36 rwx-- [ anon ]
00000000417a8000 12 0 0 ----- [ anon ]
00000000417ab000 1016 40 40 rwx-- [ anon ]
00000000418ec000 12 0 0 ----- [ anon ]
00000000418ef000 1016 40 40 rwx-- [ anon ]
00000000419ed000 12 0 0 ----- [ anon ]
00000000419f0000 1016 36 36 rwx-- [ anon ]
0000000041aee000 12 0 0 ----- [ anon ]
0000000041af1000 1016 40 40 rwx-- [ anon ]
0000000041c54000 12 0 0 ----- [ anon ]
0000000041c57000 1016 36 36 rwx-- [ anon ]
0000000041d55000 12 0 0 ----- [ anon ]
0000000041d58000 1016 8 8 rwx-- [ anon ]
0000000041e56000 4 0 0 ----- [ anon ]
0000000041e57000 1024 8 8 rwx-- [ anon ]
0000000041f57000 12 0 0 ----- [ anon ]
0000000041f5a000 1016 44 44 rwx-- [ anon ]
0000000042058000 12 0 0 ----- [ anon ]
000000004205b000 1016 68 68 rwx-- [ anon ]
0000000042159000 12 0 0 ----- [ anon ]
000000004215c000 1016 32 32 rwx-- [ anon ]
000000005e532000 10308 10272 10272 rwx-- [ anon ]
00000000eb200000 5312 5312 5312 rwx-- [ anon ]
00000000eb730000 80704 0 0 rwx-- [ anon ]
00000000f0600000 10752 5856 5856 rwx-- [ anon ]
00000000f1080000 161280 0 0 rwx-- [ anon ]
00000000fae00000 21248 11144 11144 rwx-- [ anon ]
00000000fc2c0000 62720 0 0 rwx-- [ anon ]
0000003ac7e00000 112 104 0 r-x-- ld-2.5.so
0000003ac801c000 4 4 4 r-x-- ld-2.5.so
0000003ac801d000 4 4 4 rwx-- ld-2.5.so
0000003ac8200000 1336 540 0 r-x-- libc-2.5.so
0000003ac834e000 2048 0 0 ----- libc-2.5.so
0000003ac854e000 16 16 8 r-x-- libc-2.5.so
0000003ac8552000 4 4 4 rwx-- libc-2.5.so
0000003ac8553000 20 20 20 rwx-- [ anon ]
0000003ac8600000 8 8 0 r-x-- libdl-2.5.so
0000003ac8602000 2048 0 0 ----- libdl-2.5.so
0000003ac8802000 4 4 4 r-x-- libdl-2.5.so
0000003ac8803000 4 4 4 rwx-- libdl-2.5.so
0000003ac8a00000 88 64 0 r-x-- libpthread-2.5.so
0000003ac8a16000 2044 0 0 ----- libpthread-2.5.so
0000003ac8c15000 4 4 4 r-x-- libpthread-2.5.so
0000003ac8c16000 4 4 4 rwx-- libpthread-2.5.so
0000003ac8c17000 16 4 4 rwx-- [ anon ]
0000003ac8e00000 520 20 0 r-x-- libm-2.5.so
0000003ac8e82000 2044 0 0 ----- libm-2.5.so
0000003ac9081000 4 4 4 r-x-- libm-2.5.so
0000003ac9082000 4 4 4 rwx-- libm-2.5.so
0000003ac9e00000 28 20 0 r-x-- librt-2.5.so
0000003ac9e07000 2048 0 0 ----- librt-2.5.so
0000003aca007000 4 4 4 r-x-- librt-2.5.so
0000003aca008000 4 4 4 rwx-- librt-2.5.so
0000003acc600000 84 24 0 r-x-- libnsl-2.5.so
0000003acc615000 2044 0 0 ----- libnsl-2.5.so
0000003acc814000 4 4 4 r-x-- libnsl-2.5.so
0000003acc815000 4 4 4 rwx-- libnsl-2.5.so
0000003acc816000 8 0 0 rwx-- [ anon ]
0000003acce00000 68 52 0 r-x-- libresolv-2.5.so
0000003acce11000 2048 0 0 ----- libresolv-2.5.so
0000003acd011000 4 4 4 r-x-- libresolv-2.5.so
0000003acd012000 4 4 4 rwx-- libresolv-2.5.so
0000003acd013000 8 4 0 rwx-- [ anon ]
00002aaaaaaab000 8 8 0 r-xs- gcb.jar
00002aaaaaaad000 32 32 0 r-xs- resources.jar
00002aaaaaaba000 52 52 0 r-x-- libverify.so
00002aaaaaac7000 1020 0 0 ----- libverify.so
00002aaaaabc6000 12 12 12 rwx-- libverify.so
00002aaaaabc9000 164 132 0 r-x-- libjava.so
00002aaaaabf2000 1020 0 0 ----- libjava.so
00002aaaaacf1000 28 20 20 rwx-- libjava.so
00002aaaaacf8000 4 4 0 r-x-- [ anon ]
00002aaaaacf9000 4 4 4 rwx-- [ anon ]
00002aaaaacfa000 32 32 12 rwxs- 18503
00002aaaaad08000 40 24 0 r-x-- libnss_files-2.5.so
00002aaaaad12000 2044 0 0 ----- libnss_files-2.5.so
00002aaaaaf11000 4 4 4 r-x-- libnss_files-2.5.so
00002aaaaaf12000 4 4 4 rwx-- libnss_files-2.5.so
00002aaaaaf13000 56 56 0 r-x-- libzip.so
00002aaaaaf21000 1032 0 0 ----- libzip.so
00002aaaab023000 12 12 12 rwx-- libzip.so
00002aaaab026000 2500 1168 1168 rwx-- [ anon ]
00002aaaab297000 46656 0 0 rwx-- [ anon ]
00002aaaae027000 40 40 40 rwx-- [ anon ]
00002aaaae031000 728 0 0 rwx-- [ anon ]
00002aaaae0e7000 12 12 12 rwx-- [ anon ]
00002aaaae0ea000 156 0 0 rwx-- [ anon ]
00002aaaae111000 24 24 24 rwx-- [ anon ]
00002aaaae117000 312 0 0 rwx-- [ anon ]
00002aaaae165000 44 44 44 rwx-- [ anon ]
00002aaaae170000 120 0 0 rwx-- [ anon ]
00002aaaae18e000 28 16 16 rwx-- [ anon ]
00002aaaae195000 316 0 0 rwx-- [ anon ]
00002aaaae1e4000 44 24 24 rwx-- [ anon ]
00002aaaae1ef000 124 0 0 rwx-- [ anon ]
00002aaaae20e000 1632 1632 0 r-xs- rt.jar
00002aaaae3a6000 208 208 208 rwx-- [ anon ]
00002aaaae3da000 55144 44 0 r-x-- locale-archive
00002aaab19b4000 160 160 0 r-xs- bcprov-jdk15-146.jar
00002aaab19dc000 28 28 0 r-xs- mysql-connector-java-5.1.13-bin.jar
00002aaab19e3000 24 24 0 r-xs- commons-configuration-1.6.jar
00002aaab19e9000 20 20 0 r-xs- commons-lang-2.5.jar
00002aaab19ee000 8 8 0 r-xs- commons-logging-1.1.1.jar
00002aaab19f0000 56 56 0 r-xs- commons-collections-3.2.1.jar
00002aaab19fe000 12 12 0 r-xs- jce.jar
00002aaab1a01000 24 24 0 r-xs- jsse.jar
00002aaab1a07000 12 12 0 r-xs- sunjce_provider.jar
00002aaab1a0a000 76 72 0 r-x-- libnet.so
00002aaab1a1d000 1028 0 0 ----- libnet.so
00002aaab1b1e000 12 12 12 rwx-- libnet.so
00002aaab1b2f000 16 16 0 r-x-- libnss_dns-2.5.so
00002aaab1b33000 2044 0 0 ----- libnss_dns-2.5.so
00002aaab1d32000 4 4 4 r-x-- libnss_dns-2.5.so
00002aaab1d33000 4 4 4 rwx-- libnss_dns-2.5.so
00002aaab4000000 16432 3272 3272 rwx-- [ anon ]
00002aaab500c000 49104 0 0 ----- [ anon ]
00002b29fc3a7000 8 8 8 rwx-- [ anon ]
00002b29fc3b7000 28 16 0 r-x-- libjli.so
00002b29fc3be000 1028 0 0 ----- libjli.so
00002b29fc4bf000 8 8 8 rwx-- libjli.so
00002b29fc4c1000 12 12 12 rwx-- [ anon ]
00002b29fc4c4000 9320 6500 0 r-x-- libjvm.so
00002b29fcdde000 1032 0 0 ----- libjvm.so
00002b29fcee0000 1748 608 608 rwx-- libjvm.so
00002b29fd095000 232 164 164 rwx-- [ anon ]
00007fff13b03000 84 44 44 rwx-- [ stack ]
00007fff13b34000 16 4 0 r-x-- [ anon ]
ffffffffff600000 8192 0 0 ----- [ anon ]
---------------- ------ ------ ------
total kB 601248 49456 39620
Is the a good way to check it ?
Out of my 1026076 (1GB) memory available is that program really using 600K ?
Have I calculated it right ?
This is a VM server just in case the above matters if u need me to output any other commands let me know, appreciated.
I assume you're basing your conclusions on this line of your
pmap
output:If so, you're reading it wrong. Those numbers are the total number of kilobytes in use, not bytes, so your JVM has asked for about 600MB of memory, of which 49MB is actually stored in physical memory (the rest is swapped out, or committed but not in use, or whatever). A little of that memory is probably shared with other processes (the mmap'd libraries, for instance) but it's noise in comparison to your process' usage.
Why dont you use
top
?ss: http://www.thegeekstuff.com/wp-content/uploads/2010/01/top-highlight.png usage: http://linux.about.com/od/commands/l/blcmdl1_top.htm