====== Java G1 GC ====== * [[java:gc|Java Garbage Collection]] ===== 기본 설정 ===== -XX:+UseG1GC -XX:+DisableExplicitGC -XX:+UseStringDeduplication * ''-XX:MaxGCPauseMillis=밀리세컨드'' default=200ms * ''-XX:G1HeapRegionSize=숫자m'' 보통은 Heap size 기준으로 2018개로 리젼을 나누면서 사이즈가 1mb~32mb 되도록 최선으로 결정되지만 사용하는 데이터 종류에 따라 직접 지정가능. 2의 제곱으로 지정할 것. * ''-XX:ParallelGCThreads=숫자'' * ''-XX:ConcGCThreads=숫자'' * ''-XX:+UseStringDeduplication'' : 불필요한 문자열 중복 생성 방지 G1 에서만 기능함 [[https://dzone.com/articles/easy-change-to-reduce-memory-by-20|G1 GC: Reducing Memory Consumption by 20%]] ===== Java 8 Metaspace Class Unloading ===== * [[https://blogs.oracle.com/poonam/long-class-unloading-pauses-with-jdk8|Long Class-Unloading Pauses with JDK8 | Poonam Bajaj's Blog]] JDK 8 G1 GC에서는 class 영역이 클 경우 class unloading을 하는 gc 시간이 매우 길어질 수 있다. 다음 옵션으로 대부분 문제가 없어진다. 매우 오래전 기록이므로 최신 JVM에서 불필요하게 미리 설정하지 말 것. -XX:+UseLargePagesInMetaspace ===== 주의 ===== * ''-Xmn''과 ''-XX:NewRation''는 사용하지 말 것. * ''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.'' ===== 참조 ===== * Java 7 u60 이상 버전에서 G1 GC 사용할 것. 그 이하버전에 버그가 좀 많다고 함. * [[https://www.oracle.com/technical-resources/articles/java/g1gc.html|Garbage First Garbage Collector Tuning]] * [[https://bugs.openjdk.java.net/browse/JDK-8038348|[JDK-8038348] Instance field load is replaced by wrong data Phi]] : [[search:lucene|Lucene]] 사용에 영향을 끼치는 G1 GC Bug * [[http://www.infoq.com/articles/G1-One-Garbage-Collector-To-Rule-Them-All|G1: One Garbage Collector To Rule Them All]] G1 GC 작동 원리에 대한 상세한 설명 * [[https://www.infoq.com/articles/tuning-tips-G1-GC|Tips for Tuning the Garbage First Garbage Collector]] * [[http://www.oracle.com/technetwork/tutorials/tutorials-1876574.html|Getting Started with the G1 Garbage Collector]] * [[https://software.intel.com/en-us/blogs/2014/06/18/part-1-tuning-java-garbage-collection-for-hbase|Part #1 - Tuning Java Garbage Collection for HBase]] * [[http://initproc.tistory.com/entry/G1-Garbage-Collection|G1 Garbage Collection (G1 GC)]] - G1 GC의 기본 개념을 잘 정리했음. * [[http://blog.mgm-tp.com/2013/03/garbage-collection-tuning/|Tuning Garbage Collection for Mission-Critical Java Applications - Tuning Guidelines for Java Garbage Collection, Part 1 « mgm technology blog]] * [[http://blog.mgm-tp.com/2013/12/benchmarking-g1-and-other-java-7-garbage-collectors/|Benchmarking G1 and other Java 7 Garbage Collectors - Tuning Guidelines for Java Garbage Collection, Part 2 « mgm technology blog]] * [[http://blog.mgm-tp.com/2014/04/controlling-gc-pauses-with-g1-collector/|Controlling GC pauses with the GarbageFirst Collector - Tuning Guidelines for Java Garbage Collection, Part 3 « mgm technology blog]] * [[http://www.slideshare.net/MonicaBeckwith/garbage-first-garbage-collector-g1-gc-migration-to-expectations-and-advanced-tuning|Garbage First Garbage Collector (G1 GC) - Migration to, Expectations …]] G1 GC 실전 예 * [[http://www.slideshare.net/MonicaBeckwith/con5497?related=2|Garbage First Garbage Collector (G1 GC): Current and Future Adaptabil…]] * [[http://www.slideshare.net/C2B2/g1-garbage-collector-big-heaps-and-low-pauses|G1 Garbage Collector - Big Heaps and Low Pauses?]] * [[https://docs.oracle.com/cd/E40972_01/doc.70/e40973/cnf_jvmgc.htm|Tuning JVM Garbage Collection for Production Deployments]] * [[https://blogs.oracle.com/poonam/entry/about_g1_garbage_collector_permanent|About G1 Garbage Collector, Permanent Generation and Metaspace]] * [[http://stackoverflow.com/questions/18960493/class-unloading-in-javas-g1-garbage-collector-g1gc|Class Unloading in Java's G1 Garbage Collector (G1GC)]] * G1 GC 에서는 Class Unloading이 자동으로 이루어진다. ''-XX:+TraceClassUnloading''로 확인 가능. * [[http://logonjava.blogspot.kr/2015/08/java-g1-gc-full-gc.html?spref=tw|Log on Java: Java G1 GC의 특성에 따른 Full GC 회피 튜닝 방법]] * [[http://blog.mgm-tp.com/2014/04/controlling-gc-pauses-with-g1-collector/|Controlling GC pauses with the GarbageFirst Collector - Tuning Guidelines for Java Garbage Collection, Part 3 « mgm technology blog]] * [[https://engineering.linkedin.com/blog/2016/11/application-pauses-when-running-jvm-inside-linux-control-groups|Application Pauses When Running JVM Inside Linux Control Groups | LinkedIn Engineering]] * Docker 사용 Linux에서 쓰레드 갯수 등 * Redhat G1 GC 자료 : 잘 정리돼 있는 듯 * [[https://www.redhat.com/en/blog/part-1-introduction-g1-garbage-collector|Part 1: Introduction to the G1 Garbage Collector]] * [[https://www.redhat.com/en/blog/collecting-and-reading-g1-garbage-collector-logs-part-2|Collecting and reading G1 garbage collector logs - part 2]] * [[https://product.hubspot.com/blog/g1gc-fundamentals-lessons-from-taming-garbage-collection|G1GC Fundamentals: Lessons from Taming Garbage Collection]] * [[https://www.slideshare.net/jelastic/elastic-jvm-automatic-vertical-scaling-of-the-java-heap|Elastic JVM: Automatic Vertical Scaling of the Java Heap]] * [[https://dzone.com/articles/java-garbage-collection-3|Java Garbage Collection - DZone Java]]