This topic describes the Java virtual machine (JVM) startup options that are used to configure the heap size and garbage collectors.
Configure the heap size
Common JVM options that are used to configure the heap size
Option | Description | Example |
| Sets the maximum heap size. |
|
| Sets the minimum heap size. |
|
| Sets the size of the young generation. |
|
| Sets the stack size of the thread. |
Note If you use JDK 5.0 or later, set this option to 1 MB. If you use earlier JDK versions, set this option to 256 KB. You can adjust the stack size of each thread based on your business requirements. In the case of the same physical memory size, a smaller value of this option indicates more threads. The number of threads in a process is limited by your OS. In most cases, a process can have 3,000 to 5,000 threads. |
| Sets the ratio of the young generation to the old generation. |
|
| Sets the ratio of the eden space to the two survivor spaces in the young generation. |
|
| Sets the maximum size of the permanent generation. |
|
| Sets the age of the objects in the young generation. |
|
Configure garbage collectors
Common garbage collector (GC) options for applications that require high throughput
Option | Description | Example |
| Instructs the JVM to use the parallel GC for the young generation. | Example: |
| Sets the number of threads that can be used at the same time by the parallel GC for garbage collection. Note We recommend that you set the number of threads and the number of GCs to the same value. | Example: |
| Instructs the JVM to use the parallel GC for the old generation. Note If you use JDK 6.0, you can select the parallel GC for the old generation. | Example: |
| Sets the maximum pause time of each garbage collection for the young generation. The JVM automatically adjusts the size of the young generation to maintain the value of this option. | Example: |
| Enables the adaptive size policy. If you configure this option, the parallel GC automatically adjusts the size of the young generation and the ratio of the survivor spaces to achieve the lowest latency or optimal garbage collection frequency. We recommend that you always enable the adaptive size policy for the parallel GC. |
|
Common GC options for applications that require low latency
Option | Description | Example |
| Instructs the JVM to use the concurrent mark sweep (CMS) GC for the old generation. Note If you configure the |
|
| Instructs the JVM to use the parallel GC for the young generation. The parallel GC and the CMS GC can be used for the young generation at the same time. If you use JDK 5.0 or later, the JVM automatically configures this option based on your system configurations. In this case, you do not need to configure this option. |
|
| The CMS GC does not compact or manage the heap space. Therefore, fragmentation occurs after the CMS GC runs for a specific period of time. As a result, the running efficiency of applications may decrease. This option specifies the number of times that a CMS GC must run through the heap before the heap space is compacted or managed. | Example: |
| Enables the compaction for the old generation heap. Note If you enable this option, the fragmentation problem can be prevented, but the system performance may be degraded. |
|
Common verbose GC options
Option | Description |
| Prints GC logs. |
| Prints GC details. |
| Prints the GC timestamp from the time when the JVM starts up to the current date. Example:
|
| Prints the GC timestamp as a date. Example:
|
| Prints the heap information before and after garbage collection. |
| Sets the output path of the log files. |