Question

I can set the Java Heap Size minimum and maximum by passing the parameters -Xms and -Xmx, respectively.

I understand that the maximum flag is necessary to limit the space, but what's the reason for setting a minimum initial heap size? If the maximum is big enough, the space will increase? Or do i miss something?

Was it helpful?

Solution

Minimun size is set so that the JVM doesn't have to "resize" the heap space if it starts off too small.

OTHER TIPS

Java will start with the minimum heap size and will try to avoid enlarging the heap by garbage collecting.

So if the steady-state memory size of your app is larger than the default heap minimum heap size, you may do a lot of pointless GC on the way to that size. Setting the min size to that size will avoid the pointless GC.

You can set the minimum heap size if your application needs a certain amount to run. If you set the maximum heap size, the jvm isn't supposed to exceed it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top