Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I just want to know the exact amount of memory one process consumes.

pgrep java -l
21786 java

The total memory I have is 1GB:

[root@home tmp]# free -m
             total       used       free     shared    buffers     cached
Mem:          1024        952         71          0          0          0
-/+ buffers/cache:        952         71
Swap:            0          0          0

java uses 413588K, that is more than 40% of memory being used by java

pmap 21786

......

b7fc2000      4K r-x--  /usr/lib/locale/en_US.utf8/LC_IDENTIFICATION
b7fc3000      4K rwx--    [ anon ]
b7fc4000      4K r-x--    [ anon ]
b7fc5000    108K r-x--  /lib/ld-2.5.so
b7fe0000      4K r-x--  /lib/ld-2.5.so
b7fe1000      4K rwx--  /lib/ld-2.5.so
bf85b000     84K rwx--    [ stack ]
 total   413588K




top - 23:40:54 up 22 days,  6:17,  5 users,  load average: 0.02, 0.04, 0.03
Tasks: 100 total,   2 running,  98 sleeping,   0 stopped,   0 zombie
Cpu(s):  1.7%us,  1.3%sy,  0.0%ni, 97.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
Mem:   1048800k total,   975180k used,    73620k free,        0k buffers
Swap:        0k total,        0k used,        0k free,        0k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
21786 mirror    19   0  403m 102m 8712 S  0.3 10.0   0:10.52 java   

Why does top result only show 10% of the memory is used by java process?

So the result of top and pmap is conflicted, the fommer indicates that more than 40% of the system memory is used by java process, but the result of top indicates that only 10% of the memory is used by java process.

Which one is correct?

How is one to know the exact amount of memory used by one process?

share|improve this question
add comment

1 Answer

You are confusing virtual memory and physical one.

pmap is reporting virtual memory statistics (413588K used) which match top VIRT column (403m). This is including data shared with other processes and other pages stored on disk.

Use pmap -x to get RAM usage statistics (RSS column).

The java process current RAM usage is reported by top RES column, 103 MB.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.