Weird JVM Heap Usage


(Brad Jungsu Heo) #1

(Sorry if this is not directly related to ES. But I don't know where to ask)

my environments

  • ES Version: 2.3.2
  • GC: CMS gc
  • Heap Size: 20GB
  • Total Ram: 64GB
  • Java Version: 1.8.0_60 Java HotSpot(TM) 64-Bit
  • OS: CentOS 7.2

Here is Heap Usage of one of my test servers

heap usage

ES only uses less than 4GB (20% of heap of 20GB)

But Java process uses 16GB of resident memory!

$ jps
53089 Elasticsearch

$ ps aux | grep 53089
username   53089  112 35.7 168712820 17672036 ?  Sl   Nov16 13599:09 /path/to/java ... -Xms20g -Xmx20g -Des.path.home=/path/to/elasticsearch -cp /path/to/elasticsearch/lib/elasticsearch-2.3.2.jar:/path/to/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch start -d

Q: Does this means, almost the most of resident memory are fragmented?

Here is jmap output:

$ jmap -histo:live 53089 | head -n 20

 num     #instances         #bytes  class name
----------------------------------------------
   1:        264406     1274923328  [B
   2:        105756      102571056  [J
   3:         98842       12137408  [C
   4:        125753        9054216  org.apache.lucene.util.fst.FST$Arc
   5:         34735        5001840  org.apache.lucene.codecs.blocktree.SegmentTermsEnumFrame
   6:        145887        4668384  org.apache.lucene.store.ByteArrayDataInput
   7:         34736        3334656  org.apache.lucene.codecs.lucene50.Lucene50PostingsFormat$IntBlockTermState
   8:         92266        2952512  java.util.HashMap$Node
...

Thank you for advenced answer.


(Jörg Prante) #2

You configured 20 GB heap for Elasticsearch, so I do not understand why you are concerned about 16 GB process size in memory. This is to be expected.


(Brad Jungsu Heo) #3

@jprante

Thank you for your reply.

Yes. It is not a problem. What I'd like to know is that...

ES uses only 2~4GB of heap but 16GB of redisdent memory. So I'd like to know what is occupying 12~14GB resident memory (heap usage graph and jmap output show this)

Thanks


(Jörg Prante) #4

The JVM allocates the whole heap at startup, no matter if it is used or not, and keeps it allocated from the OS. This for performance reasons. See -Xms and -Xmx JVM flags.


(Brad Jungsu Heo) #5

OK. I see.

I'm not a JVM guy. So I missed -Xms 20g option.

Thanks alot.


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.