-
GC Tools
- There are multiple ways to enable the GC log: specifying either of the flags -verbose:gc
or -XX:+PrintGC will create a simple GC log (the flags are aliases for each other, and by
default the log is disabled).
- The -XX:+PrintGCDetails flag will create a log with much more information. This flag is recommended (it is also false by default); it is often too difficult to diagnose what is happening with GC using only the simple log
- In conjunctionwith the detailed log, it is recommended to include -XX:+PrintGCTimeStamps or
-XX:+PrintGCDateStamps, so that the time between GC operations can be determined. The difference in those two arguments is that the timestamps are relative to 0 (based on when the JVM starts), while the date stamps are an actual date string. That makes the date stamps ever-so-slightly less efficient as the dates are formatted, though it is an infrequent enough operation that its effect is unlikely to be noticed.
- The GC log is written to standard output, though that location can be changed with the
-Xloggc:filename flag. Using -Xloggc automatically enables the simple GC log unless
PrintGCDetails has also been enabled. The amount of data that is kept in the GC log
can be limited using log rotation; this is quite useful for a long-running server that
might otherwise fill up its disk with logs over several months. Logfile rotation is
controlled with these flags: -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=N
-XX:GCLogFileSize=N. By default, UseGCLogFileRotation is disabled. When that flag
is enabled, the default number of files is 0 (meaning unlimited), and the default logfile
size is 0 (meaning unlimited). Hence, values must be specified for all these options in
order for log rotation to work as expected. Note that a logfile size will be rounded up to
8 KB for values less than that.
- For a scriptable solution, jstat is the tool of choice. jstat provides nine options to
print different information about the heap; jstat -options will provide the full list.
One useful option is -gcutil, which displays the time spent in GC as well as the percentage
of each GC area that is currently filled. Other options to jstat will display the
GC sizes in terms of KB.
- Remember that jstat takes an optional argument—the number of milliseconds to repeat
the command—so it can monitor over time the effect of GC in an application. Here
is some sample output repeated every second: jstat -gcutil process_id 1000
Summary
- GC logs are the key piece of data required to diagnose GC issues;
they should be collected routinely (even on production
servers).
- A better GC logfile is obtained with the PrintGCDetails flag.
- Programs to parse and understand GC logs are readily available;
they are quite helpful in summarizing the data in the GC
log.
- jstat can provide good visibility into GC for a live program.
-
相关阅读:
Centos6.5环境中安装vsftp服务
MySQL数据库的数据备份和恢复(导入和导出)命令操作语法【转】
linux系统被入侵后处理经历【转】
Linux lsof命令详解和使用示例【转】
Oracle 表空间和用户权限管理【转】
如何在 Linux 中找出最近或今天被修改的文件
Linux 服务器系统监控脚本 Shell【转】
1张图看懂RAID功能,6张图教会配置服务器【转】
简析TCP的三次握手与四次分手【转】
TCP协议中的三次握手和四次挥手(图解)【转】
-
原文地址:https://www.cnblogs.com/parkdifferent/p/9550544.html
Copyright © 2020-2023
润新知