Reputation: 7788
For applications with dedicated memory, does it make sense to have a lower Min Heap Size than Max Heap Size? (-Xms, -Xmx parameters) These are backend servers within a docker container.
Or is it ideal that Min and Max heap is equal?
Like is there a reason to return some memory to the system when not used in heap?
With the assumption that there are no other processes expected to perform in the background. Outside of the server operating system stuff.
Upvotes: 1
Views: 145
Reputation: 2047
According to the documentation:
Setting
-Xms
and-Xmx
to the same value increases predictability by removing the most important sizing decision from the virtual machine. However, the virtual machine is then unable to compensate if you make a poor choice.
Generally, on larger heap GC run less frequent. But there are some case when larger heap may cause performance degradation (for example libs that scan memory for object). Also with larger heap, startup is little longer, but there are no need to heap resize on runtime.
Mostly the difference is so little, that noone can recognise. But the best way to find the best jvm configuration is always the measurement. There are lot of good tool to measure performance, memory etc, for example JHM, JMC, VisualVm etc.. Every apps are different, so there are no best choice in common.
Upvotes: 3