Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why -Xms is required?

Tags:

java

memory

I understand that, -Xms and -Xmx are used for specifying minimum and maximum heap size for java program. And as per my understanding, JVM can work if we don't specify any of the options, i.e heap size can be managed by JVM itself.

So, if we want to limit maximum heap size, we should use -Xmx and that is OK, now my question is, why anybody needs to limit minimum size of heap, as it can be very well managed by JVM.

Why -Xms is required at all?

like image 951
codingenious Avatar asked Nov 12 '13 08:11

codingenious


People also ask

Why are requirements important?

Why are requirements important? They establish a foundation for product vision, scope, cost, and schedule and they ultimately must target finished product quality and performance.

Why is requirement gathering important?

Good gathering, processing and management of requirements is important as it sets clear targets for everyone to aim for. It can be a lot of hard work, but it need not be a daunting task if you can keep some key points in mind.

Which of these is the purpose of requirement?

The requirements contain the behavior, attributes, and properties of the future system. Therefore, the main task of the requirements is to ensure that they are understood by all stakeholders. The work with the requirements involves various processes, e.g. identification, analysis, verification and, finally, management.


1 Answers

You can reduce garbage collection cycles by setting a larger minimum heap size. This doesn't make a huge difference on long running programs, but short running stuff can benefit from this.

The JVM sets the initial heap size to some amount of the maximum heap size and then grows the heap and performs (mostly minor) GC runs when the used memory exceeds some threshold. So, when setting an initial heap size with -Xms (which is then immediately allocated on JVM startup) you can avoid these heap grow cycles.

like image 193
Neet Avatar answered Sep 20 '22 10:09

Neet