title: How to calculate Actual Memory usage for java using top linux?
body: <p>I need to find out What is the actual memory consumed by Java process in Linux, the tools like visualVM/jconsole shows accurate but I must calculate actual memory used by JVM through top command.</p>
  
  <p>I am looking at PID : 28169 if you look at top (linux)  , it is saying 17.2g ( virtual ) , Res 10g , Shared : 15m . 10G is not possible since I Have given 6G jvmmax to this jvm process  but if I use jvmtop it shows actuate results(matching with visualVM)<br>
  can someone shows me how to calculate actual usage of memory using top stats ?</p>
  
  <p>Using JvmTop</p>
  
  <p>JvmTop 0.8.0 alpha - 11:09:08,  amd64, 12 cpus, Linux 2.6.32-57, load avg 0.00
  <a href="http://code.google.com/p/jvmtop" rel="nofollow noreferrer">http://code.google.com/p/jvmtop</a></p>
  
  <pre><code>    PID 28169: com.gigaspaces.start.SystemBoot
  ARGS: com.gigaspaces.start.services="GSC"
  VMARGS: -XX:+AggressiveOpts -XX:MaxPermSize=256m -XX:+HeapDumpOnOutOfMemo[...]
  VM: Oracle Corporation Java HotSpot(TM) 64-Bit Server VM 1.7.0_51
  UP: 179:23m #THR: 90   #THRPEAK: 92   #THRCREATED: 3725 USER: evolv
  GC-Time:  0: 2m   #GC-Runs: 3353      #TotalLoadedClasses: 23107
  CPU:  1.46% GC:  0.00% HEAP:4623m /10240m NONHEAP: 180m / 304m
  
      TID   NAME                                    STATE    CPU  TOTALCPU BLOCKEDBY
  3733 RMI TCP Connection(2210)-10.16       RUNNABLE 14.93%     0.00%
  3734 JMX server connection timeout   TIMED_WAITING  0.13%     0.00%
  95   GS-directLoadJobListenerPollin  TIMED_WAITING  0.12%     0.14%
  94   GS-jobListenerPollingContainer  TIMED_WAITING  0.11%     0.14%
  3375 GS-jobListenerPollingContainer  TIMED_WAITING  0.10%     0.55%
  93   GS-jobListenerPollingContainer  TIMED_WAITING  0.09%     0.14%
  3377 GS-jobListenerPollingContainer  TIMED_WAITING  0.09%     0.56%
  81   GS-subJobCompleteListenerPolli  TIMED_WAITING  0.09%     0.14%
  3376 GS-jobListenerPollingContainer  TIMED_WAITING  0.08%     0.54%
  98   GS-stopJobListenerPollingConta  TIMED_WAITING  0.08%     0.14%
   Note: Only top 10 threads (according cpu load) are shown!
  ^C-bash-4.1$
  
  
  using Top : 
  
  top - 11:15:30 up 18 days,  6:34,  1 user,  load average: 0.00, 0.00, 0.00
  Tasks: 306 total,   1 running, 304 sleeping,   1 stopped,   0 zombie
  Cpu(s):  0.3%us,  0.1%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
  Mem:  16332776k total, 15913220k used,   419556k free,   316876k buffers
  Swap:  4095996k total,   146452k used,  3949544k free,  3024048k cached
  
  
  
  
  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
  28169 evolv     20   0 17.2g  10g  15m S  2.8 70.3   4493:54 java
  28034 evolv     20   0 5690m 289m 7656 S  0.0  1.8  16:31.29 java
  28006 evolv     20   0 5821m 286m 7952 S  0.5  1.8  18:16.50 java
  2098  root      20   0  272m 145m 4016 S  0.3  0.9  46:51.51 splunkd
  2163  root      20   0  128m  40m 1220 S  0.0  0.3   1:05.86 puppet
  1879  root      20   0  244m 6660 5036 S  0.0  0.0   1:21.82 sssd_be
  </code></pre>