You can control the JVM heap settings using a set of parameters known as non-standard options, which are prefixed by the –X
flag. Our analysis will be split into three main areas:
At first, we will review the parameters that define the minimum and maximum heap sizes.
After that, we will inspect the flags which can be used to fine-tune the Young /tenured generation ratio.
Finally, we will examine the most complex part, which concerns the garbage collector behavior and that can be further optimized by choosing the optimal garbage collector algorithm.
You can configure the desired heap size using two switches: the –Xms
option lets you decide the initial heap size. On the other hand, the –Xmx
option is where you can set the maximum memory granted to the heap. If JVM tries to reclaim more memory when the maximum heap size is reached, a message saying java.lang.OutOfMemoryError: Java heap space
is issued.
For example, the following command launches...