Q:

Java heap size is 20x greater then -Xmx - How is that possible?

An Elasticsearch instance is running on a VM with 32 core CPU and 120gb memory.
While I was debugging for a performance issue found this result for htop
Mem usage 

Elastic search Java process consuming 52% of memory ~60gb

jstat result
jstat -gc 11660
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
195904.0 195904.0  0.0   30111.4 1567680.0 1146433.0 59906496.0 1432277.9  73684.0 63888.5  0.0    0.0   2122077 150951.979   6      0.837 150952.816

The -Xms2g and -Xmx2g settings are clearly visible for the java process.
How is this possible ? How can the memory usage go beyond -Xmx2g ?

A:

What top and htop don't show is the level of the JVM heap, which is different from the total physical memory consumed by the Java process.
Underneath, Lucene will map the index segment files directly into memory without leveraging the heap. So, in your Java process, Elasticsearch itself might well make use of a 2GB heap, but the underlying Lucene library might consume much more memory depending on how big the segments that need to be loaded into memory are.
Another answer on the same subject: https://stackoverflow.com/a/35232221/4604579

