简体   繁体   English

垃圾收集

[英]Garbage Collection

垃圾回收(GC)信息的日志记录选项可帮助您调整堆大小或诊断与内存有关的任何其他问题,它是由什么完成的?

-verbose:gc is what you want. -verbose:gc是您想要的。

Take a look at GCPortal for more related information. 请查看GCPortal了解更多相关信息。

JConsole can be used to monitor the garbage collection graphically, which can be useful sometimes for identifying trends etc. JConsole可用于以图形方式监视垃圾收集,有时可用于识别趋势等。

In short 简而言之

  • -XX:PrintGCDetails - timings and space sizes for each GC phase -XX:PrintGCDetails每个GC阶段的时间和空间大小
  • -XX:+PrintGCDateStamps - add timestamps to gC logs -XX:+PrintGCDateStamps向gC日志添加时间戳
  • -XX:+PrintReferenceGC - helps to find reference abuse -XX:+PrintReferenceGC帮助查找参考滥用
  • -XX:+PrintPromotionFailure
  • -XX:+PrintGCApplicationStoppedTime - report all safe points not just GC -XX:+PrintGCApplicationStoppedTime报告所有安全点而不仅仅是GC

More comprehensive list of GC options . 更全面的GC选项列表

The garbage collection logging depends on the type of JVM you are using. 垃圾收集日志记录取决于您使用的JVM的类型。 There are different parameters to enable GC logging depending on the JVM being used. 根据所使用的JVM,有不同的参数可启用GC日志记录。 Below are parameters that need to be included to enable GC logging: 以下是启用GC日志记录所需包含的参数:

SUN JVM : -XX:+PrintGCDetails -XX:+PrintGCDateStamps (It will print both time and date) -verbose:gc -Xloggc:/path/gc.log SUN JVM :-XX:+ PrintGCDetails -XX:+ PrintGCDateStamps(它将同时打印时间和日期)-verbose:gc -Xloggc:/path/gc.log

Note- -XX:+PrintGCTimeStamps (It will print the time after JVM restart in seconds and not the time stamp in hh:mm:ss format. This is somewhat difficult to interpret so it is recommended to use PrintGCDateStamps instead) 注--XX:+ PrintGCTimeStamps(它将以秒为单位打印JVM重新启动后的时间,而不是以hh:mm:ss格式显示时间戳。这有点难以解释,因此建议改用PrintGCDateStamps)

JRockit -Xverbose -XverboseTimeStamp -Xverboselog:/path/gc.log JRockit -Xverbose -XverboseTimeStamp -Xverboselog:/path/gc.log

IBMJ9 -verbose:gc IBMJ9-详细 :gc

You may want to look at Java Flight Recorder, which gives you complete GC statistics with very less overhead. 您可能需要查看Java Flight Recorder,它为您提供了完整的GC统计信息,而其开销却很小。 You can start JFR recording while the Application is running. 您可以在应用程序运行时开始JFR记录。 The output file generated will have detailed info on the GC statistics. 生成的输出文件将具有有关GC统计信息的详细信息。 You have to open the output jfr file using Java Mission Control. 您必须使用Java Mission Control打开输出的jfr文件。

I used to work with these options to analyze GC performance for Sun/OpenJDK JVM: 我曾经使用以下选项来分析Sun / OpenJDK JVM的GC性能:

# print détails GC info #打印细节GC信息

-XX:+PrintGCDetails

# print date stamps at GC events in order to correlate them with applications issues #在GC事件上打印日期戳,以便将它们与应用程序问题相关联

-XX:+PrintGCDateStamps

# print HEAP Usage (before GC, after GC, Young Gen, Old Gen, ...). #打印HEAP使用情况(GC之前,GC之后,Young Gen,Old Gen等)。

-XX:+PrintHeapAtGC

# print reference processing time during STW pause #在STW暂停期间打印参考处理时间

-XX:+PrintReferenceGC

# print Young Gen décision made by JVM. #打印JVM生成的Young Gendécision。 helpful if you didn't set a size for Young Gen with NewRation option 如果您没有使用NewRation选项设置Young Gen的大小,将很有帮助

-XX:+PrintAdaptiveSizePolicy

# add GC causes to logs (System.gc, promotion failure, concurrent mode failure, ...) #将GC原因添加到日志中(System.gc,升级失败,并发模式失败等)

-XX:+PrintGCCause

# add details for promotion failure #添加促销失败的详细信息

-XX:+PrintPromotionFailure

# print distribution of java objects that populate the Youn Gen based on their age. #打印根据年龄划分的Java对象分布。 Helpful to see if your Eden and survivor spaces are well sized 有助于查看您的伊甸园和幸存者空间是否足够大

-XX:+PrintTenuringDistribution

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM