What is the reason for setting a minimum Java heap size?

I can set the minimum and maximum Java heap size by passing the -Xms and -Xmx respectively.

I understand that the maximum flag is necessary to limit the space, but what is the reason for setting the minimum size of the initial heap? If the maximum is large enough, will the space increase? Or am I missing something?

+3
source share
3 answers

The Minimun size is set so that the JVM does not have to โ€œresizeโ€ the heap if it starts too small.

+5
source

Java will start with a minimum heap size and try to avoid heap growth by garbage collection.

So, if the size of your applicationโ€™s stationary memory is larger than the default minimum heap size, you can make a lot of pointless GC on the way to that size. Setting the minimum size to this size avoids the pointless GC.

+2
source

You can set a minimum heap size if your application needs a certain amount to run. If you specify the maximum heap size, jvm should not exceed it.

0
source

Source: https://habr.com/ru/post/915823/


All Articles