====== Java Garbage Collection ====== * [[java:g1gc|G1 GC]] * **GC 옵션은 어떤 상황에서든 명시적으로 지정하는게 좋다.** * 메모리가 ''1792mb'' 이하이면 Serial GC로 기본 지정된다. 이는 심각한 성능저하를 일으킨다. * https://twitter.com/brunoborges/status/1499114848516329472?s=20&t=MA20XuqUuG50dnOvqXIXqw ===== 공식문서 ===== * [[https://docs.oracle.com/en/java/javase/11/gctuning/introduction-garbage-collection-tuning.html|Java 11 GC Tuning]] * [[https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/|Java 8 GC Tuning]] ===== 참조 ===== * [[https://johngrib.github.io/wiki/java-gc-tuning/|Java GC 튜닝 - 기계인간 John Grib]] * [[http://www.oracle.com/technetwork/java/javase/gc-tuning-6-140523.html|Java SE 6 HotSpot[tm] Virtual Machine Garbage Collection Tuning]] * [[http://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/index.html|Java 8 GC Tuning]] * [[http://blog.dynatrace.com/2011/05/11/how-garbage-collection-differs-in-the-three-big-jvms/|How Garbage Collection differs in the three big JVMs]] * [[http://blog.dynatrace.com/2011/04/20/the-top-java-memory-problems-part-1/|The Top Java Memory Problems – Part 1]] * [[http://helloworld.naver.com/helloworld/6043|HelloWorld » Garbage Collection 모니터링 방법]] * [[http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html#overview|Getting Started with the G1 Garbage Collector]] * [[http://blog.naver.com/bumsukoh/110119881124|Java GC 로그 분석]] * [[http://www.cubrid.org/blog/dev-platform/how-to-tune-java-garbage-collection/|How to tune java gc]] * [[http://helloworld.naver.com/helloworld/1329|hello world » Java Garbage Collection 한국어 설명]] * [[http://helloworld.naver.com/helloworld/6043|hello world » Garbage Collection 모니터링 방법]] * [[http://helloworld.naver.com/helloworld/37111|hello world » Garbage Collection 튜닝]] * [[http://helloworld.naver.com/helloworld/329631|hello world » Java Reference와 GC]] * [[http://blog.takipi.com/garbage-collectors-serial-vs-parallel-vs-cms-vs-the-g1-and-whats-new-in-java-8/|Garbage Collectors - Serial vs. Parallel vs. CMS vs. G1 (and what’s new in Java 8) | Takipi Blog]] * [[http://www.javacodegeeks.com/2015/04/7-things-you-thought-you-knew-about-garbage-collection-and-are-totally-wrong.html|7 Things You Thought You Knew About Garbage Collection – and Are Totally Wrong]] * [[http://blog.ragozin.info/2011/09/hotspot-jvm-garbage-collection-options.html|JVM GC Options]] * [[http://www.poalsoft.com/blog/?p=34|JVM Tuning – Garbage Collection]] * [[http://gceasy.io/|GC Easy]] Web GC Log Analyzer * [[https://d2.naver.com/helloworld/37111|Garbage Collection 튜닝]] * [[https://www.baeldung.com/java-verbose-gc|Verbose Garbage Collection in Java | Baeldung]] * [[https://www.javacodegeeks.com/2017/11/minimize-java-memory-usage-right-garbage-collector.html|Minimize Java Memory Usage with the Right Garbage Collector]] * [[https://jelastic.com/blog/java-ram-usage-in-containers-top-5-tips-not-to-lose-your-memory/|Java RAM Usage in Containers: 5 Tips Not to Lose Memory]] * [[https://jelastic.com/blog/stop-overpaying-for-java-cloud-hosting-resources/|5 Steps to Stop Overpaying for Java Cloud Hosting Resources]] ===== GC Log===== * [[http://helloworld.naver.com/helloworld/6043|Garbage Collection 모니터링 방법]] * GC 상태 보기 * ''-verbose:gc'' * ''-XX:+PrintGCDetails'' * ''-XX:+PrintGCTimeStamps'' * ''-XX:+PrintHeapAtGC'' * ''-XX:+PrintGCDateStamps'' (from JDK 6 update 4) 이 옵션은 사용하지 말고 GC 시간을 정리해보여주는 스크립트 사용할것. * ''-XX:+PrintReferenceGC'' * ''-XX:+PrintGCApplicationStoppedTime'' * ''-XX:+PrintClassHistogramAfterFullGC'' * ''-XX:+PrintClassHistogramBeforeFullGC'' * ''-Xloggc:'' : GC 로그를 ''file''로 남긴다. * ''-XX:+HeapDumpAfterFullGC'' * ''-XX:+HeapDumpBeforeFullGC'' * ''-XX:+HeapDumpOnOutOfMemoryError'' * ''-XX:HeapDumpPath='' * ''-XX:-TraceClassUnloading -XX:-TraceClassLoading'' : class loading/unloading 로깅 * [[https://h20392.www2.hp.com/portal/swdepot/displayProductInfo.do?productNumber=HPJMETER|HPJMeter]] ''verbose:gc''결과 분석 * gc 로그에 ''PrintGCDateStamps'' 이 옵션으로 인한 날짜 정보가 있으면 날짜 관련 부분을 지워야한다. * [[https://github.com/chewiebug/GCViewer|GCViewer]] Java 6/7 지원, ''PrintGCDateStamps''지원. * [[http://176.34.122.30/blog/2010/05/26/human-readable-jvm-gc-timestamps/|Human readable JVM GC timestamps – The Server Labs Blog]] * [[http://robertmaldon.blogspot.kr/2007/09/more-human-friendly-java-gc-timestamps.html|robertmaldon: More human-friendly Java GC timestamps]] * [[http://fasterj.com/tools/gcloganalysers.shtml|Garbage Collector Log Analysers]] * [[https://dzone.com/articles/understanding-g1-gc-log-format|Understanding G1 GC Log Format]] * [[https://github.com/microsoft/gctoolkit|microsoft/gctoolkit: Tool for parsing GC logs]] ===== GC Log Rotate - Java 6 u34 이상, Java 7 ===== * [[http://jyates.github.io/2012/11/05/rolling-java-gc-logs.html|Rolling Java GC Logs]] * [[http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html|vmoptions]] 참조 * ''-XX:+UseGCLogFileRotation'' : 기본 false, 지정만 하면 바로 true. * ''-XX:NumberOfGCLogFiles'' : 기본 0. Rotate 안 함. * ''-XX:GCLogFileSize'' : 기본 0. Rotate 안 함. 최소 8k 이상. java -Xloggc:gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps \ -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=128K ===== Microsoft GC Toolkit ===== * [[https://devblogs.microsoft.com/java/introducing-microsoft-gctoolkit/|Introducing Microsoft GCToolkit | Java at Microsoft]]