如何从 JVM 分析和监控 gc.log 垃圾收集器日志文件

发布于 2024-12-26 10:35:42 字数 184 浏览 2 评论 0原文

我想知道直观分析和监视 java gc.log 文件的最佳方法是什么。

GCViewer 是迄今为止我发现的最有趣的工具,但我想知道是否有更好的工具或者是监视多个远程 gc.log 文件的良好解决方案。

I'm wondering what is the best way to visually analyse and monitor java gc.log files.

GCViewer is the most interesting tool I've found so far, but I'm wondering if there is anything better or a good solution for monitoring multiple remote gc.log files.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蓬勃野心 2025-01-02 10:35:42

我认为分析垃圾收集器日志的最有效方法是查看输出本身。我们的生产服务器都使用并发标记扫描收集器运行,并且我使用选项 -Xloggc:$GCLOGFILE -XX:+PrintGCDetails 运行日志,如果环境遇到问题,我

  1. 首先检查数量通过 grep 查找“Full GC”来查看 Full GC,并
  2. 检查 CMS 的数量和频率,并在收集阶段查找错误消息(通常以“failed to...”开头)。

我通常还会查看线程列表并检查垃圾收集器消耗的 cpu 时间量。我通过使用 -p 参数运行 top 并随后按“H”来完成此操作,这样您就可以看到消耗最多 cpu 时间的 pid。然后可以将其与线程转储相匹配,以查看 gc 线程是否是最耗时的线程。每个线程都有一个 pid 显示在线程转储中,该 pid 为十六进制,可以与顶部的 pid 相匹配。

查看 GC 消耗的 cpu 时间并将其与日志输出相匹配非常重要。我多次尝试使用 GCViewer,但从未真正从 GC 数据的可视化显示中获得有用的提示。

I think the most effective way for analyzing the garbage collector log is by looking at the output itself. Our production server all run using the Concurrent Mark Sweep Collector and I have the log running with the options -Xloggc:$GCLOGFILE -XX:+PrintGCDetails and if the environment runs into problems I

  1. first check for the amount of Full GC by grepping for "Full GC" and
  2. Check the amount and frequency of the CMS and look for error messages in the collection phase (usually start with "failed to...").

I usually also look at the thread list and check the amount of cpu time the Garbage Collector consumes. I do this by running top with the -p <java-pid> Parameter and press "H" afterwards, with this you get to see the pids which consume the most cpu time. This then can be matched to a Thread Dump to see if gc threads are the most time consuming threads. Every thread has a pid displayed in the thread dump, which is in hex, this can be matched to the pids in top.

It is quite important to see the cpu times the GC consumes and match this to your log output. I tried the GCViewer several times but never really got useful hints from the visual display of the GC-Data.

巷子口的你 2025-01-02 10:35:42

您可以使用 JDK 中包含的 jconsole 工具。或者当您运行java应用程序时,可以使用参数“-verbose:gc”。

You can use the jconsole tool which is included into the JDK. Or when you run a java application, you can use the parameter "-verbose:gc" .

今天小雨转甜 2025-01-02 10:35:42

我认为您可以使用选项在日志文件中记录 gc 活动:

-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:gc.log

您可以使用 HPJmeter 等软件利用此日志

I think you can use options to log gc activity in a log file :

-verbose:gc -XX:+PrintGCTimeStamps -XX:+PrintGCDetails -Xloggc:gc.log

You can exploit this log with software as HPJmeter

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文