There is a server on which I cannot run any GUI-based profilers such as jvisualvm to monitor the heap of a running Java process. According to this answer, I can use jstat -gc <pid>
and look at the OU and OC columns to find out the heap usage and allocation.
But I just compared jvisualvm and jstat on another server, and they do not show the same numbers for the heap usage and allocation.
Jvisualvm shows that a Java process has about 1GB allocated for the heap and about 500MB of it is used:
But for that same process, jstat shows only about 700MB under the OC column and about 226MB under the OU column:
# jstat -gc 39621
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
16384.0 17920.0 3984.0 0.0 322560.0 10320.4 699392.0 226295.2 83968.0 47921.1 11966 66.103 12 3.083 69.186
Why are jvisualvm and jstat showing different numbers for the heap usage and allocation?