15

I'm running jstat -gc (from OpenJDK):

# jstat -gc 1
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
287744.0 290304.0 88368.6  0.0   1469440.0 787186.5 2162176.0  1805969.7  945432.0 923880.4 136576.0 133284.0    268   32.797  21     30.089   62.886

How to read:

  1. used heap

  2. heap size

  3. max heap

from this output, just like shown by VisualVM?

Yuri
  • 4,254
  • 1
  • 29
  • 46
X. Wo Satuk
  • 923
  • 1
  • 11
  • 18
  • 5
    If you are insterested only in those three values, maybe `jmap -heap ` would better fit your needs. – SubOptimal May 02 '17 at 13:20
  • Nice. Max heap (3) is shown in MaxHeapSize. Used heap (1) is sum of "used" in Eden Space, From Space, To Space, and PS Old Generation. But how to get heap size (2)? – X. Wo Satuk May 02 '17 at 14:43
  • 2
    Also, unfortunately `jmap` in OpenJDK doesn't have `-heap` param... Any alternatives? – X. Wo Satuk May 02 '17 at 14:44
  • Which OpenJDK version are you using? I can see the option here (openjdk version "1.8.0_131"). – SubOptimal May 03 '17 at 06:48
  • `openjdk8-8.111.14-r0` Alpine Linux package, `javac -version` shows `javac 1.8.0_111-internal` – X. Wo Satuk May 03 '17 at 12:13
  • I did a check. Updateing Alpine Linux to 3.5/3.6 doesn't bring you up to `131`, as it's simply not yet available. see https://blogs.oracle.com/developers/official-docker-image-for-oracle-java-and-the-openjdk-roadmap-for-containers – SubOptimal May 05 '17 at 07:15

1 Answers1

15

See https://docs.oracle.com/javase/8/docs/technotes/tools/unix/jstat.html for general reference.

Current heap size would be the sum of all the fields that end with "C" - S0C, S1C, EC, OC (except for metaspace which is the fields that start with "M")

Used heap would be the sum of all the fields that end with "U" - S0U, S1U, EU, OU (again, except metaspace).

Note that the "C" values (current) are greater than or equal to "U" values (actually used).

To get maximum values run jstat with the -gccapacity flag and add up all the fields that end with "MX" (NGCMX, OGCMX, ... except for MCMX which is metaspace).

Yuri
  • 4,254
  • 1
  • 29
  • 46
S. D.
  • 788
  • 5
  • 15