Description

이 옵션들을 Java HotSpot VM으로부터 GC가 실행되는 방법을 제어한다.

Options

-XX:+AggressiveHeap

Java heap optivization을 활성화한다. 컴퓨터 구성(RAM 및 CPU)을 기반으로 집중적인 메모리 할당으로 장시간 실행되는 잡에 최적화되도록 다양한 파라미터를 설정한다. 이 옵션은 기본적으로 비활성화 되어있고 힙이 최적화되지 않는다.

-XX:+AlwaysPreTouch

JVM 초기화 중에 Java 힙의 모든 페이지에 touching 할 수 있게 한다. main() 메서드에 들어가기 전에 메모리의 모든 메이지를 가져온다. 이 옵션은 물리 메모리에 매핑된 모든 가상 메모리로 장시간 실행되는 시스템을 시뮬레이션하는 테스트에 사용될 수 있으며, 기본적으로 비활성화되어 있고, all pages are committed as JVM heap space fills.

-XX:+CMSClassUnloadingEnabled

Enables class unloading when using the concurrent mark-sweep (CMS) garbage collector. This option is enabled by default. To disable class unloading for the CMS garbage collector, specify -XX:-CMSClassUnloadingEnabled.

-XX:CMSExpAvgFactor=percent

Sets the percentage of time (0 to 100) used to weight the current sample when computing exponential averages for the concurrent collection statistics. By default, the exponential averages factor is set to 25%. The following example shows how to set the factor to 15%:

-XX:CMSExpAvgFactor=15

-XX:CMSInitiatingOccupancyFraction=percent

Sets the percentage of the old generation occupancy (0 to 100) at which to start a CMS collection cycle. The default value is set to -1. Any negative value (including the default) implies that -XX:CMSTriggerRatio is used to define the value of the initiating occupancy fraction.

The following example shows how to set the occupancy fraction to 20%:

-XX:CMSInitiatingOccupancyFraction=20

-XX:+CMSScavengeBeforeRemark

Enables scavenging attempts before the CMS remark step. By default, this option is disabled.

-XX:CMSTriggerRatio=percent

Sets the percentage (0 to 100) of the value specified by -XX:MinHeapFreeRatio that is allocated before a CMS collection cycle commences. The default value is set to 80%.

The following example shows how to set the occupancy fraction to 75%:

-XX:CMSTriggerRatio=75

-XX:ConcGCThreads=threads

Sets the number of threads used for concurrent GC. The default value depends on the number of CPUs available to the JVM.

For example, to set the number of threads for concurrent GC to 2, specify the following option:

-XX:ConcGCThreads=2

-XX:+DisableExplicitGC

System.gc() 에 대한 호출 처리를 비활성화하는 옵션이다. 이 옵션은 기본적으로 비활성화 되어 있으므로, `System.gc()`에 대한 호출이 처리된다. 이 옵션이 비활성화되어 있을지라도 필요할 경우에 JVM은 GC를 수행한다.

-XX:+ExplicitGCInvokesConcurrent

Enables invoking of concurrent GC by using the System.gc() request. This option is disabled by default and can be enabled only together with the -XX:+UseConcMarkSweepGC option.

-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses

Enables invoking of concurrent GC by using the System.gc() request and unloading of classes during the concurrent GC cycle. This option is disabled by default and can be enabled only together with the -XX:+UseConcMarkSweepGC option.

-XX:G1HeapRegionSize=size

G1 콜렉터를 사용할 때 Java 힙이 분할되는 영역의 크기를 설정한다. 이 값은 1MB ~ 32MB 로 설정할 수 있으며, 기본 영역 사이즈는 힙 사이즈를 기반으로 ergonomically하게 결정된다.

다음 예제는 subdivisions의 사이즈는 16MB로 설정하는 방법이다:

-XX:G1HeapRegionSize=16m

-XX:+G1PrintHeapRegions

G1 콜렉터에서 할당된 영역과 회수된 영역 대한 정보를 출력한다. 기본적으로 이 옵션은 비활성화되어 있다.

-XX:G1ReservePercent=percent

Sets the percentage of the heap (0 to 50) that is reserved as a false ceiling to reduce the possibility of promotion failure for the G1 collector. By default, this option is set to 10%.

The following example shows how to set the reserved heap to 20%:

-XX:G1ReservePercent=20

-XX:InitialHeapSize=size

Sets the initial size (in bytes) of the memory allocation pool. This value must be either 0, or a multiple of 1024 and greater than 1 MB. Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes. The default value is chosen at runtime based on system configuration. See the section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage Collection Tuning Guide at http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

The following examples show how to set the size of allocated memory to 6 MB using various units:

-XX:InitialHeapSize=6291456
-XX:InitialHeapSize=6144k
-XX:InitialHeapSize=6m

If you set this option to 0, then the initial size will be set as the sum of the sizes allocated for the old generation and the young generation. The size of the heap for the young generation can be set using the -XX:NewSize option.

-XX:InitialSurvivorRatio=ratio

Sets the initial survivor space ratio used by the throughput garbage collector (which is enabled by the -XX:+UseParallelGC and/or -XX:+UseParallelOldGC options). Adaptive sizing is enabled by default with the throughput garbage collector by using the -XX:+UseParallelGC and -XX:+UseParallelOldGC options, and survivor space is resized according to the application behavior, starting with the initial value. If adaptive sizing is disabled (using the -XX:-UseAdaptiveSizePolicy option), then the -XX:SurvivorRatio option should be used to set the size of the survivor space for the entire execution of the application.

The following formula can be used to calculate the initial size of survivor space (S) based on the size of the young generation (Y), and the initial survivor space ratio ®:

S=Y/(R+2) The 2 in the equation denotes two survivor spaces. The larger the value specified as the initial survivor space ratio, the smaller the initial survivor space size.

By default, the initial survivor space ratio is set to 8. If the default value for the young generation space size is used (2 MB), the initial size of the survivor space will be 0.2 MB.

The following example shows how to set the initial survivor space ratio to 4:

-XX:InitialSurvivorRatio=4

-XX:InitiatingHeapOccupancyPercent=percent

Sets the percentage of the heap occupancy (0 to 100) at which to start a concurrent GC cycle. It is used by garbage collectors that trigger a concurrent GC cycle based on the occupancy of the entire heap, not just one of the generations (for example, the G1 garbage collector).

By default, the initiating value is set to 45%. A value of 0 implies nonstop GC cycles. The following example shows how to set the initiating heap occupancy to 75%:

-XX:InitiatingHeapOccupancyPercent=75

-XX:MaxGCPauseMillis=time

최대 GC 일시 정지 시간(밀리초)을 설정한다. 이 설정 값은 soft한 목표치로 JVM은 이를 달성하기 위해 노력하며, 기본 값은 빈 값이다.

다음 예제는 최대 일시 정지 시간을 500ms로 설정하는 방법이다:

-XX:MaxGCPauseMillis=500

-XX:MaxHeapSize=size

Sets the maximum size (in byes) of the memory allocation pool. This value must be a multiple of 1024 and greater than 2 MB. Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes. The default value is chosen at runtime based on system configuration. For server deployments, -XX:InitialHeapSize and -XX:MaxHeapSize are often set to the same value. See the section "Ergonomics" in Java SE HotSpot Virtual Machine Garbage Collection Tuning Guide at http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html.

다음 예제는 다양한 단위를 사용하여 할당된 메모리의 최대치를 80MB로 설정하는 방법이다:

-XX:MaxHeapSize=83886080
-XX:MaxHeapSize=81920k
-XX:MaxHeapSize=80m

Oracle Solaris 7 와 Oracle Solaris 8 SPARC 플랫폼에서는 the upper limit for this value is approximately 4,000 MB minus overhead amounts. Oracle Solaris 2.6 와 x86 플랫폼에서는 the upper limit is approximately 2,000 MB minus overhead amounts. Linux 플랫폼에서는 the upper limit is approximately 2,000 MB minus overhead amounts.

The -XX:MaxHeapSize option is equivalent to -Xmx.

-XX:MaxHeapFreeRatio=percent

Sets the maximum allowed percentage of free heap space (0 to 100) after a GC event. If free heap space expands above this value, then the heap will be shrunk. By default, this value is set to 70%.

The following example shows how to set the maximum free heap ratio to 75%:

-XX:MaxHeapFreeRatio=75
-XX:MaxMetaspaceSize=size

Sets the maximum amount of native memory that can be allocated for class metadata. By default, the size is not limited. The amount of metadata for an application depends on the application itself, other running applications, and the amount of memory available on the system.

The following example shows how to set the maximum class metadata size to 256 MB:

-XX:MaxMetaspaceSize=256m

-XX:MaxNewSize=size

young generation(nursery)을 위한 최대 힙 사이즈(바이트)를 설정한다. 기본적으로, 이 값은 ergonomically하게 설정된다.

-XX:MaxTenuringThreshold=threshold

Sets the maximum tenuring threshold for use in adaptive GC sizing. The largest value is 15. The default value is 15 for the parallel (throughput) collector, and 6 for the CMS collector.

The following example shows how to set the maximum tenuring threshold to 10:

-XX:MaxTenuringThreshold=10

-XX:MetaspaceSize=size

Sets the size of the allocated class metadata space that will trigger a garbage collection the first time it is exceeded. This threshold for a garbage collection is increased or decreased depending on the amount of metadata used. The default size depends on the platform.

-XX:MinHeapFreeRatio=percent

Sets the minimum allowed percentage of free heap space (0 to 100) after a GC event. If free heap space falls below this value, then the heap will be expanded. By default, this value is set to 40%.

The following example shows how to set the minimum free heap ratio to 25%:

-XX:MinHeapFreeRatio=25

-XX:NewRatio=ratio

Sets the ratio between young and old generation sizes. By default, this option is set to 2. The following example shows how to set the young/old ratio to 1:

-XX:NewRatio=1

-XX:NewSize=size

Sets the initial size (in bytes) of the heap for the young generation (nursery). Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes.

The young generation region of the heap is used for new objects. GC is performed in this region more often than in other regions. If the size for the young generation is too low, then a large number of minor GCs will be performed. If the size is too high, then only full GCs will be performed, which can take a long time to complete. Oracle recommends that you keep the size for the young generation between a half and a quarter of the overall heap size.

The following examples show how to set the initial size of young generation to 256 MB using various units:

-XX:NewSize=256m
-XX:NewSize=262144k
-XX:NewSize=268435456

The -XX:NewSize option is equivalent to -Xmn.

-XX:ParallelGCThreads=threads

Sets the number of threads used for parallel garbage collection in the young and old generations. The default value depends on the number of CPUs available to the JVM.

For example, to set the number of threads for parallel GC to 2, specify the following option:

-XX:ParallelGCThreads=2

-XX:+ParallelRefProcEnabled

parallel reference processing 을 활성화한다. 기본적으로, 이 옵션은 비활성화되어 있다.

-XX:+PrintAdaptiveSizePolicy

adaptive generation sizing 에 대한 정보를 출력한다. 기본적으로, 이 옵션은 비활성화되어 있다.

-XX:+PrintGC

모든 GC에서 메시지를 출력하며, 기본적으로 이 옵션은 비활성화되어 있다.

-XX:+PrintGCApplicationConcurrentTime

Enables printing of how much time elapsed since the last pause (for example, a GC pause). By default, this option is disabled.

-XX:+PrintGCApplicationStoppedTime

Enables printing of how much time the pause (for example, a GC pause) lasted. By default, this option is disabled.

-XX:+PrintGCDateStamps

모든 GC에서 날짜 스탬프를 출력한다. 기본적으로 이 옵션은 비활성화되어 있다.

-XX:+PrintGCDetails

모든 GC에서 디테일한 메시지를 출력한다. 기본적으로 이 옵션은 비활성화되어 있다.

-XX:+PrintGCTaskTimeStamps

Enables printing of time stamps for every individual GC worker thread task. By default, this option is disabled.

-XX:+PrintGCTimeStamps

모든 GC에서 타임 스탬프를 출력한다. 기본적으로 이 옵션은 비활성화되어 있다.

-XX:+PrintStringDeduplicationStatistics

디테일한 중복 제거 통계를 출력한다. 기본적으로 이 옵션은 비활성되어 있으며, -XX:+UseStringDeduplication 을 참조하라.

-XX:+PrintTenuringDistribution

Enables printing of tenuring age information. The following is an example of the output:

Desired survivor size 48286924 bytes, new threshold 10 (max 10)
- age 1: 28992024 bytes, 28992024 total
- age 2: 1366864 bytes, 30358888 total
- age 3: 1425912 bytes, 31784800 total
...

Age 1 objects are the youngest survivors (they were created after the previous scavenge, survived the latest scavenge, and moved from eden to survivor space). Age 2 objects have survived two scavenges (during the second scavenge they were copied from one survivor space to the next). And so on.

In the preceding example, 28 992 024 bytes survived one scavenge and were copied from eden to survivor space, 1 366 864 bytes are occupied by age 2 objects, etc. The third value in each row is the cumulative size of objects of age n or less.

By default, this option is disabled.

-XX:+ScavengeBeforeFullGC

Enables GC of the young generation before each full GC. This option is enabled by default. Oracle recommends that you do not disable it, because scavenging the young generation before a full GC can reduce the number of objects reachable from the old generation space into the young generation space. To disable GC of the young generation before each full GC, specify -XX:-ScavengeBeforeFullGC.

-XX:SoftRefLRUPolicyMSPerMB=time

Sets the amount of time (in milliseconds) a softly reachable object is kept active on the heap after the last time it was referenced. The default value is one second of lifetime per free megabyte in the heap. The -XX:SoftRefLRUPolicyMSPerMB option accepts integer values representing milliseconds per one megabyte of the current heap size (for Java HotSpot Client VM) or the maximum possible heap size (for Java HotSpot Server VM). This difference means that the Client VM tends to flush soft references rather than grow the heap, whereas the Server VM tends to grow the heap rather than flush soft references. In the latter case, the value of the -Xmx option has a significant effect on how quickly soft references are garbage collected.

The following example shows how to set the value to 2.5 seconds:

-XX:SoftRefLRUPolicyMSPerMB=2500

-XX:StringDeduplicationAgeThreshold=threshold

String objects reaching the specified age are considered candidates for deduplication. An object’s age is a measure of how many times it has survived garbage collection. This is sometimes referred to as tenuring; see the -XX:+PrintTenuringDistribution option. Note that String objects that are promoted to an old heap region before this age has been reached are always considered candidates for deduplication. The default value for this option is 3. See the -XX:+UseStringDeduplication option.

-XX:SurvivorRatio=ratio

Sets the ratio between eden space size and survivor space size. By default, this option is set to 8. The following example shows how to set the eden/survivor space ratio to 4:

-XX:SurvivorRatio=4

-XX:TargetSurvivorRatio=percent

Sets the desired percentage of survivor space (0 to 100) used after young garbage collection. By default, this option is set to 50%.

The following example shows how to set the target survivor space ratio to 30%:

-XX:TargetSurvivorRatio=30

-XX:TLABSize=size

Sets the initial size (in bytes) of a thread-local allocation buffer (TLAB). Append the letter k or K to indicate kilobytes, m or M to indicate megabytes, g or G to indicate gigabytes. If this option is set to 0, then the JVM chooses the initial size automatically.

The following example shows how to set the initial TLAB size to 512 KB:

-XX:TLABSize=512k

-XX:+UseAdaptiveSizePolicy

Enables the use of adaptive generation sizing. This option is enabled by default. To disable adaptive generation sizing, specify -XX:-UseAdaptiveSizePolicy and set the size of the memory allocation pool explicitly (see the -XX:SurvivorRatio option).

-XX:+UseCMSInitiatingOccupancyOnly

Enables the use of the occupancy value as the only criterion for initiating the CMS collector. By default, this option is disabled and other criteria may be used.

-XX:+UseConcMarkSweepGC

Enables the use of the CMS garbage collector for the old generation. Oracle recommends that you use the CMS garbage collector when application latency requirements cannot be met by the throughput (-XX:+UseParallelGC) garbage collector. The G1 garbage collector (-XX:+UseG1GC) is another alternative.

By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM. When this option is enabled, the -XX:+UseParNewGC option is automatically set and you should not disable it, because the following combination of options has been deprecated in JDK 8: -XX:+UseConcMarkSweepGC -XX:-UseParNewGC.

-XX:+UseG1GC

garbage-first (G1) garbage collector의 사용을 활성화한다. 이것은 대량의 RAM이 있는 멀티프로세스 시스템을 대상으로 하는 서버-스타일 GC이다. 우수한 처리량을 유지하면서, 높은 활률로 stop-the-world 시간 목표를 충족한다. G1 컬렉터는 제한된 GC latency time(0.5초 미만의 안적정이고 예측 가능한 stop-the-world 시간)에서 큰 힙(6 GB 혹은 그 이상)이 필요한 어플리케이션에 권장된다.

기본적으로 이 옵션은 비활성화 되어 있고, collector는 시스템의 구성과 JVM의 타입에 따라 자동으로 선택된다.

-XX:+UseGCOverheadLimit

OutOFMemoryError 예외를 던지기 전에 GC에서 JVM이 소비한 시간 비율을 제한하는 정책을 사용하는 것을 활성화한다. 만약, 전체 시간의 98 % 이상이 가비지 수집에 소비되고 힙의 2 % 미만이 복구되는 경우에 Parallel GC는 OutOfMemoryError를 던질 것이다. When the heap is small, this feature can be used to prevent applications from running for long periods of time with little or no progress. 이 옵션을 비활성화 하려면 다음과 같이 설정한다: -XX:-UseGCOverheadLimit

-XX:+UseNUMA

Enables performance optimization of an application on a machine with nonuniform memory architecture (NUMA) by increasing the application’s use of lower latency memory. By default, this option is disabled and no optimization for NUMA is made. The option is only available when the parallel garbage collector is used (-XX:+UseParallelGC).

-XX:+UseParallelGC

Enables the use of the parallel scavenge garbage collector (also known as the throughput collector) to improve the performance of your application by leveraging multiple processors.

By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM. If it is enabled, then the -XX:+UseParallelOldGC option is automatically enabled, unless you explicitly disable it.

-XX:+UseParallelOldGC

Enables the use of the parallel garbage collector for full GCs. By default, this option is disabled. Enabling it automatically enables the -XX:+UseParallelGC option.

-XX:+UseParNewGC

Enables the use of parallel threads for collection in the young generation. By default, this option is disabled. It is automatically enabled when you set the -XX:+UseConcMarkSweepGC option. Using the -XX:+UseParNewGC option without the -XX:+UseConcMarkSweepGC option was deprecated in JDK 8.

-XX:+UseSerialGC

Enables the use of the serial garbage collector. This is generally the best choice for small and simple applications that do not require any special functionality from garbage collection. By default, this option is disabled and the collector is chosen automatically based on the configuration of the machine and type of the JVM.

-XX:+UseSHM

On Linux, enables the JVM to use shared memory to setup large pages.

For more information, see "Large Pages".

-XX:+UseStringDeduplication

문자열 중복 제거를 활성화한다. 기본적으로 이 옵션은 비활성화되어있다. 이 옵션을 사용하려면 G1GC를 활성화해야 한다(-XX:+UseG1GC 옵션 참조).

문자열 중복 제거는 많은 String 객체가 동일하다는 사실을 이용하여 Java 힙에서 String 객체의 메모리 사용 공간을 줄인다. 자기 자신의 문자 배열을 가르키는 각 String 객체 대신에 동일한 문자 배열을 가리키고 공유할 수 있게 한다.

-XX:+UseTLAB

Enables the use of thread-local allocation blocks (TLABs) in the young generation space. This option is enabled by default. To disable the use of TLABs, specify -XX:-UseTLAB.

Reference