G1에 대한 Java 7 (JDK 7) 가비지 콜렉션 및 문서
Java 7 은 한동안 출시 되었지만 가비지 수집기 , 특히 새로운 G1 수집기 의 구성에 대한 좋은 리소스를 찾을 수 없습니다 .
내 질문 :
- G1은 Java 7의 기본 수집기이며 그렇지 않은 경우 어떻게 G1을 활성화합니까?
- Java7에서 g1의 선택적 설정은 무엇입니까?
- cms 또는 Java 7 의 병렬 수집기 와 같은 다른 수집기에 변경된 사항이 있습니까?
- Java 7의 가비지 컬렉션에 대한 좋은 문서는 어디에서 찾을 수 있습니까?
G1 가비지 수집기는 Java 버전 1.7.0_01의 기본값이 아닙니다. 몇 가지 추가 명령 줄 옵션을 사용하여 직접 확인할 수 있습니다.
> java -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -version
-XX:InitialHeapSize=132304640 -XX:MaxHeapSize=2116874240 -XX:ParallelGCThreads=4 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedOops -XX:-UseLargePagesIndividualAllocation -XX:+UseParallelGC
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
Heap
PSYoungGen total 37696K, used 1293K [0x00000007d5eb0000, 0x00000007d88c0000, 0x0000000800000000)
eden space 32320K, 4% used [0x00000007d5eb0000,0x00000007d5ff3408,0x00000007d7e40000)
from space 5376K, 0% used [0x00000007d8380000,0x00000007d8380000,0x00000007d88c0000)
to space 5376K, 0% used [0x00000007d7e40000,0x00000007d7e40000,0x00000007d8380000)
PSOldGen total 86144K, used 0K [0x0000000781c00000, 0x0000000787020000, 0x00000007d5eb0000)
object space 86144K, 0% used [0x0000000781c00000,0x0000000781c00000,0x0000000787020000)
PSPermGen total 21248K, used 2032K [0x000000077ca00000, 0x000000077dec0000, 0x0000000781c00000)
object space 21248K, 9% used [0x000000077ca00000,0x000000077cbfc288,0x000000077dec0000)
하지만 더 이상 G1 수집기를 켜기 위해 실험 옵션을 활성화 할 필요는 없습니다.
> java -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseG1GC -version
-XX:InitialHeapSize=132304640 -XX:MaxHeapSize=2116874240 -XX:+PrintCommandLineFlags -XX:+PrintGCDetails -XX:+UseCompressedOops -XX:+UseG1GC -XX:-UseLargePagesIndividualAllocation
java version "1.7.0_01"
Java(TM) SE Runtime Environment (build 1.7.0_01-b08)
Java HotSpot(TM) 64-Bit Server VM (build 21.1-b02, mixed mode)
Heap
garbage-first heap total 130048K, used 0K [0x000000077ca00000, 0x0000000784900000, 0x00000007fae00000)
region size 1024K, 1 young (1024K), 0 survivors (0K)
compacting perm gen total 20480K, used 2032K [0x00000007fae00000, 0x00000007fc200000, 0x0000000800000000)
the space 20480K, 9% used [0x00000007fae00000, 0x00000007faffc288, 0x00000007faffc400, 0x00000007fc200000)
No shared spaces configured.
좋은 문서를 어디서 찾을 수 있는지 모르겠습니다.
Oracle은 마침내 Java 7 U4에서 G1을 공식화했습니다. http://www.oracle.com/technetwork/java/javase/7u4-relnotes-1575007.html
설명 : http://docs.oracle.com/javase/7/docs/technotes/guides/vm/G1.html
명령 줄 옵션 : http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html#G1Options
그래도 Java 7의 기본 수집기라고 생각하지 않습니다. 서버의 경우 기본값은 Java 6에서와 같이 Parallel Collector입니다.
예, G1은 Java 1.7 JVM의 새로운 표준 가비지 수집기입니다.
여기 에서 새 가비지 수집기를 사용하고 구성하는 방법에 대한 많은 정보를 찾을 수 있습니다.
G1 사용 G1은 여전히 실험적인 것으로 간주되며 다음 두 가지 매개 변수로 활성화 할 수 있습니다.
-XX : + UnlockExperimentalVMOptions -XX : + UseG1GC
GC 일시 중지 시간 목표를 설정하려면 다음 매개 변수를 사용하십시오.
-XX : MaxGCPauseMillis = 50 (일시 중지 시간 목표가 50ms 인 경우)
G1을 사용하면 GC 일시 중지가 위에 제공된 시간보다 오래 지속되지 않는 시간 간격을 지정할 수 있습니다.
-XX : GCPauseIntervalMillis = 200 (일시 중지 간격 목표가 200ms 인 경우)
위의 두 옵션은 약속이나 보장이 아닌 목표를 나타냅니다. 어떤 상황에서는 잘 작동하지만 다른 상황에서는 잘 작동하지 않을 수 있으며 GC가 항상이를 준수 할 수있는 것은 아닙니다.
또는 젊은 세대의 크기를 명시 적으로 지정하여 대피 일시 중지 시간에 영향을 줄 수 있습니다.
-XX : + G1YoungGenSize = 512m (512MB 젊은 세대의 경우)
G1은 또한 당연히 일련의 (잠재적으로 비 연속적) 영역 인 생존자 공간에 해당하는 공간을 사용합니다. 크기는 일반적인 매개 변수 (예 : -XX : SurvivorRatio = 6)로 지정할 수 있습니다.
마지막으로 G1을 최대한 활용하려면 드문 경쟁 조건을 발견 할 수 있으므로 현재 기본적으로 비활성화되어있는 다음 두 매개 변수를 설정해보십시오.
-XX : + G1ParallelRSetUpdatingEnabled -XX : + G1ParallelRSetScanningEnabled
한 가지 더 주목할 점은 -XX : + PrintGCDetails가 설정된 경우 G1이 다른 HotSpot GC에 비해 매우 장황하다는 것입니다. 이는 프로파일 링 및 문제 해결에 매우 도움이되는 GC 스레드 별 타이밍 및 기타 정보를 인쇄하기 때문입니다. 보다 간결한 GC 로그를 원하면 -verbosegc 사용으로 전환하십시오 (더 자세한 GC 로그를 확보하는 것이 좋습니다).
나는 또한 이 기사가 G1의 내부를 이해하는 데 매우 도움 이 된다는 것을 발견 했습니다 .
1. G1이 Java 7의 기본 수집기입니까? (...)
이 Java 5 페이지 의 규칙 은 Java 7 (및 AFAIK, Java 8)에서 계속 적용됩니다.
일 서버급 병렬 콜렉터 (-XX : + UseParallelGC) 서버 VM을 실행하는 시스템, 가비지 컬렉터 (GC)는 이전의 일련 콜렉터 (+ UseSerialGC - XX)로 변경 하였다.
그러나 다음 사항도 고려하십시오.
- 64 비트 JVM은
-client
VM 과 함께 제공되지 않으므로 항상 "서버 클래스"입니다. - Java 7부터 -XX : + UseParallelGC (설정 여부에 관계없이)를 사용하면 -XX : + UseParallelOldGC (즉, 명시 적으로 비활성화되지 않은 경우)가 추가로 의미됩니다.
예를 들어 Windows x64에서 실행하는 경우 ...
- Java 7 64 비트의 경우 기본적으로 Parallel GC (젊은 세대 및 이전 세대 모두)가 제공됩니다.
- Java 8 32 비트, 기본적으로 직렬 GC (두 세대 모두)가 제공됩니다.
1. (...) G1을 어떻게 활성화합니까?
Java 7부터 간단히 -XX:+UseG1GC
. 아마 또한 정보입니다 때 당신이 원하는 것 :
현재 CMS 또는 ParallelOld 가비지 수집기와 함께 실행되는 응용 프로그램은 응용 프로그램에 다음 특성 중 하나 이상이있는 경우 G1로 전환하는 데 도움이됩니다.
- Java 힙의 50 % 이상이 라이브 데이터로 채워져 있습니다.
- 개체 할당 비율 또는 승격 비율은 크게 다릅니다.
- 원하지 않는 긴 가비지 수집 또는 압축 일시 중지 (0.5 ~ 1 초 이상)
2. Java7에서 g1의 선택적 설정은 무엇입니까?
I've not used G1 myself, but I gather that it adheres to the same basic "throughput / ergonomic" flags used to tune the other parallel collectors. In my experience with the Parallel GC, -XX:GCTimeRatio
has been the pivotal one in providing the expected speed-memory tradeoff. YMMV.
G1-specific options are listed here
3. Were there changes to (...) cms or the parallel collector in Java 7?
Don't know, but...
G1 is planned as the long term replacement for the Concurrent Mark-Sweep Collector (CMS)
4. Where can I find good documentation on garbage collection in Java 7?
It can be a pain to find, can't it? Probably the best "hub" page I've found is this one:
http://www.oracle.com/technetwork/java/javase/tech/index-jsp-140228.html
Some deep reading required, but worth the time if you need to do some tuning. Particularly insightful is: Garbage Collector Ergonomics
- Is G1 the default collector in Java 7 and if not how do I activate G1?
G1 is not default collector in Java 7. -XX:+UseG1GC
will enable G1GC
- What optional settings does g1 have in Java7?
There are many. Have a look at this oracle article for complete information.
The G1 GC is an adaptive garbage collector with defaults that enable it to work efficiently without modification.
Due to this reason, customize critical parameters
-XX:MaxGCPauseMillis
-XX:G1HeapRegionSize
-XX:ParallelGCThreads
-XX:ConcGCThreads
and leave all other parameters to default value.
Here is a list of important options and their default values. This list applies to the latest Java HotSpot VM, build 24. You can adapt and tune the G1 GC settings on the JVM command line.
Important Defaults:
-XX:G1HeapRegionSize=n
Sets the size of a G1 region. The value will be a power of two and can range from 1MB to 32MB. The goal is to have around 2048 regions based on the minimum Java heap size.
-XX:MaxGCPauseMillis=200
Sets a target value for desired maximum pause time. The default value is 200 milliseconds. The specified value does not adapt to your heap size.
-XX:G1NewSizePercent=5
Sets the percentage of the heap to use as the minimum for the young generation size. The default value is 5 percent of your Java heap.
-XX:G1MaxNewSizePercent=60
Sets the percentage of the heap size to use as the maximum for young generation size. The default value is 60 percent of your Java heap.
-XX:ParallelGCThreads=n
Sets the value of the STW worker threads. Sets the value of n to the number of logical processors. The value of n is the same as the number of logical processors up to a value of 8.
If there are more than eight logical processors, sets the value of n to approximately 5/8 of the logical processors. This works in most cases except for larger SPARC systems where the value of n can be approximately 5/16 of the logical processors.
-XX:ConcGCThreads=n
Sets the number of parallel marking threads. Sets n to approximately 1/4 of the number of parallel garbage collection threads (ParallelGCThreads).
-XX:InitiatingHeapOccupancyPercent=45
Sets the Java heap occupancy threshold that triggers a marking cycle. The default occupancy is 45 percent of the entire Java heap.
-XX:G1MixedGCLiveThresholdPercent=65
Sets the occupancy threshold for an old region to be included in a mixed garbage collection cycle. The default occupancy is 65 percent
-XX:G1HeapWastePercent=10
Sets the percentage of heap that you are willing to waste. The Java HotSpot VM does not initiate the mixed garbage collection cycle when the reclaimable percentage is less than the heap waste percentage
-XX:G1MixedGCCountTarget=8
Sets the target number of mixed garbage collections after a marking cycle to collect old regions with at most G1MixedGCLIveThresholdPercent live data. The default is 8 mixed garbage collections
-XX:G1OldCSetRegionThresholdPercent=10
Sets an upper limit on the number of old regions to be collected during a mixed garbage collection cycle. The default is 10 percent of the Java heap
-XX:G1ReservePercent=10
Sets the percentage of reserve memory to keep free so as to reduce the risk of to-space overflows. The default is 10 percent. When you increase or decrease the percentage, make sure to adjust the total Java heap by the same amount.
You have re-configured many G1GC parameters, which are not required if you follow above documentation page. Please cross check with above recommendations especially on ParallelGCThreads and ConcGCThreads, which are to be based on your CPU cores. Remove re-configuration of un-necessary parameters.
Recommendations from oracle:
When you evaluate and fine-tune G1 GC, keep the following recommendations in mind:
Young Generation Size: Avoid explicitly setting young generation size with the
-Xmn
option or any or other related option such as-XX:NewRatio
. Fixing the size of the young generation overrides the target pause-time goal.Pause Time Goals: When you evaluate or tune any garbage collection, there is always a latency versus throughput trade-off. The G1 GC is an incremental garbage collector with uniform pauses, but also more overhead on the application threads. The throughput goal for the G1 GC is 90 percent application time and 10 percent garbage collection time.
- Were there any changes made to other collectors like cms or the parallel collector in Java 7?
There are some changes with Java 7. Have a look at this article
- Where can I find good documentation on garbage collection in Java 7?
Refer to oracle documentation page about gc and related SE question:
Java G1 garbage collection in production
The documentation available at http://www.oracle.com/technetwork/java/javase/tech/g1-intro-jsp-135488.html (the link provided by Wojtek) seems to be the only official link with info but the info seems outdated as some of the flags mentioned there were only available in the test builds, they no longer exist in the production releases. Some one from Oracle should provide some updated documentation on the G1 GC.
No G1 is not default garbage collector in jdk 1.7.0_02. The default garbage collector depends upon the class of machine. If the machine is of Server class then the default garbage collector is Throughput Collector. If the machine is of Client class then the default garbage collector is Serial Collector.
By default you don't really want to use G1 collector, as it is not really better than the others. It is only good for special purposes.
In low latency application is is sligthly better than CMS, as it has a little bit shorter, and more predictable pause times. In exchange the throughput is much worse than CMS in exchange.
So it is only good if the latency is important, but the throughput is not important at all. If both are important, then stay with CMS.
참고URL : https://stackoverflow.com/questions/8111310/java-7-jdk-7-garbage-collection-and-documentation-on-g1
'Programing' 카테고리의 다른 글
파이썬 클래스의 __dict __.__ dict__ 속성은 무엇입니까? (0) | 2020.10.08 |
---|---|
Python의 블록 범위 (0) | 2020.10.08 |
배경 Drawable을 설정할 때 패딩은 어디에 있습니까? (0) | 2020.10.08 |
Task.WhenAll에서 AggregateException이 발생하는 이유는 무엇입니까? (0) | 2020.10.08 |
파이썬에서 상속의 요점은 무엇입니까? (0) | 2020.10.08 |