Managing generation size

Several java command options allow you to manage the initial size and maximum size of the combined young and tenured generations.
-Xms

sets the initial size for the combined young and tenured generation. The default initial size is 1024 MB. Smaller values lead to shorter but more frequent garbage collections, whereas larger values lead to longer but less frequent garbage collections. For large server applications, Hewlett Packard Enterprise recommends that the initial size must be equal to the -Xmx.

specifies the maximum size of the memory allocation pool in bytes. This value must be a multiple of 1024 and greater than 8 MB. If you specify less than 16 MB, heap size is set automatically to 16 MB. The default value is 1 GB.
  • You must consider the amount of physical memory available on the system while choosing a value for -Xmx. If the virtual memory of a process exceeds the physical memory, then memory thrashing occurs and the application performance slows down.

  • Hewlett Packard Enterprise recommends that the application specifies the same value for -Xms and -Xmx. If only -Xmx is specified in the command-line, the default value used for -Xms is the same value that is specified for -Xmx.

  • When the Java heap size is specified using the Java options [-XX:MaxHeapSize, -XX:InitialHeapSize, -Xms , and -Xmx] , JVM aligns the specified value to 8 MB.

  • The virtual space of a process must not exceed the size of the physical memory. If the physical memory size is 32 GB, the maximum Java heap size is around 28 GB (2 GB for JVM memory requirement, and 2 GB for C heap, thread stack, and 28 GB for Java heap).

-XX:MetaspaceSize=<n>

Where <n> is an initial size of the metaspace. The default metaspace size is 20.7 MB.

-XX:MaxMetaspaceSize=<n>

Where <n> is an maximum size of the metaspace. By default, there is no limit on the metaspace size and is limited by the available virtual memory.

-XX:MaxMetaspaceExpansion=<n>

Where <n> is the maximum metaspace expansion size. By default, the metaspace is expanded by a maximum value of 5312 KB.