0

I am running a SolrCloud on k8s with the following setting:

Heap params:

-server -Xms280m -Xmx312m

Other params:

-XX:+UseParallelGC -XX:+UseParallelOldGC -XX:+UseAdaptiveSizePolicy -XX:ParallelGCThreads=4 -XX:AdaptiveSizePolicyOutputInterval=1 -XX:MinHeapFreeRatio=20 -XX:MaxHeapFreeRatio=40 -XX:MaxGCPauseMillis=300 -XX:GCTimeRatio=19 -XX:AdaptiveSizePolicyWeight=90 -XX:MaxMetaspaceSize=128m -XX:MaxMetaspaceFreeRatio=90 -XX:MetaspaceSize=96m -XX:+ParallelRefProcEnabled

And the max heap shown on the admin page is only 277.5m, which is 34.5m less than Xmx

enter image description here

And if I change the heap params to

-server -Xms312m -Xmx312m

Then the max heap is around 300m, which is much closer to the Xmx

My questions is that:

  • Why is there such a big difference in the first setting?
  • Why does the difference get smaller when I set Xms = Xmx
  • Would JVM still honor my Xmx setting? (Would my application still be allowed to grow to 312m?)

More observations...

I've tried this with another memory setting:

-server -Xms296m -Xmx360m

and the max heap shown on Solr's admin UI is 320m

After doing some math, it seems that the max heap is always around 90% of the Xmx I set.

  312 * 0.9 = 280.8 (just 3.3m more than 277.5m)
  360 * 0.9 = 324  (just 4m more than 320m)

Why is this happening?

1 Answers1

0

So here is some details.

-Xmx = maximum java heap

-Xms = initial and minimum java heap

The -Xmx option and -Xms option in combination are used to limit the Java heap size. The Java heap can never grow larger than -Xmx. Also, the -Xms value can be used as “minimum heap size” to set a fixed heap size by setting -Xms = -Xmx.

However -Xmx does not limit the total amount of memory that the JVM can use.

Here is my answer inline

Why is there such a big difference in the first setting?

It's because of difference between initial memory and max memory heap.

Why does the difference get smaller when I set Xms = Xmx

For production system I would suggest use same, reason is you will get kick start and less gc most of the time, again it's depend on workload and system profiling and nature of application.

Would JVM still honor my Xmx setting? (Would my application still be allowed to grow to 312m?)

Answer is yes, but don't confuse with Xmx and JVM. Heap will grow when application need more resources.

EDIT 1:

Heap having these 3 parts:

  1. Eden
  2. Survivor
  3. Tenured
  4. Reserved

Per your snapshot it shows 3 parts till 195.13MB till 209.50MB till 277.50MB and rest if reserved.

Hope this will help.

asktyagi
  • 2,401
  • 1
  • 5
  • 19
  • Hi sorry .... I am still a bit confused... in the first setting, I set -Xmx312m, why is the max heap shown on Solr's admin page only 277.5m? – John the Traveler Mar 28 '20 at 04:44
  • So, you assigned -Xms280m which mean process start with 280mb if required it will consume more and reachout to Xms. 280mb/312mb doesn't assigned complete jvm hold some memory for it's own internal purpose. – asktyagi Mar 28 '20 at 04:51
  • Hi! do you mean reach out to Xmx? – John the Traveler Mar 28 '20 at 05:15
  • say you started your program and -Xms is 280m it's start with 280m memory but used heapsize will be > 280 since jvm reserve some memory, if gradually it reached to 312m also it's will use > 312mb memory due to reservation for memory management. – asktyagi Mar 28 '20 at 05:23
  • So... can I say 277.5m is the initial heap bound set by Xms (Xmx is the max upper bound)? But this way what is the number 209.5m shown in the picture? – John the Traveler Mar 28 '20 at 08:11
  • Edited my answer with more details. – asktyagi Mar 28 '20 at 08:38
  • thanks! do you mean the following? , 195.13MB : Eden , 195.13MB ~ 209.50MB Survivor , 209.50MB ~ 277.50MB Tenured But I don't think I ever saw Eden area this big... Have I mistaken something? – John the Traveler Mar 28 '20 at 11:20
  • Enable gc logging you will get each details. – asktyagi Mar 28 '20 at 11:26
  • Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/106036/discussion-between-john-the-traveler-and-asktyagi). – John the Traveler Mar 28 '20 at 13:03