What's the reason to set a minimal Java Heap Size?
Asked Answered
H

3

2

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?

Hawkie answered 10/11, 2011 at 20:36 Comment(0)
M
5

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

Margarettamargarette answered 10/11, 2011 at 20:38 Comment(0)
L
2

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.

Lippe answered 10/11, 2011 at 20:40 Comment(0)
S
0

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.

Shcherbakov answered 10/11, 2011 at 20:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.