The Xmx and Xms settings are most commonly overlooked settings but yet quite critical for the JVM to perform as expected. They control the JVM's heap: the memory area where objects are instantiated.
The settings that we can use for tunning the JVM are:
With these settings the JVM will try to keep as close as possible to the Xms and grow up to Xmx. We'll have to keep in mind that:
Oracle recommends setting the -Xms equal to the -Xmx for minimizing garbage collections, but it's not always the best setting. The best way of adjusting these settings it to keep an eye on the JVM statistics (JConsole is a good start) to be able to adjust these settings to the needs of your application.
Keep in mind that these settings are just for the JVM's heap. The JVM is going to use more memory for other areas than just the size allocated to the heap
Posted on 15/04/2021