- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在处理 com.sun.management.GcInfo 类的一些烦恼。我通过添加 GC 通知监听器改进了我们的服务器日志。每当发生主要 GC 时,我都会记录它所花费的持续时间(以及其他一些内容)。“官方”方法是为 GarbageCollectorMXBean bean 添加通知监听器。一切都按预期进行。我了解 GC 的情况,对于每个 GarbageCollector 我都会得到一个com.sun.management.GcInfo 具有持续时间的对象。我的烦恼是当前文档 7u51 声明持续时间的值以毫秒为单位。我也在 7u11 下运行我们的服务器应用程序,持续时间似乎长了 1000 => 微秒。有人有这方面的信息吗?他们在哪个 Java 版本中改变了这一点?
最佳答案
这是一个bug在 JVM 中。 GcInfo 方法返回刻度而不是毫秒。
错误描述是这样说的:
When grabbing GarbageCollectorMXBean from the ManagementFactory, it is NOW possible (in Java 7) to cast the underlying bean implementation into a NotificationBroadcaster and add a NotificationListener. Doing this causes the JVM to report on GC events after they're done. In the JVM, GCNotifier::pushNotification puts the "raw" GCStatInfo data (containing start/end ticks) onto the request queue. GCNotifier::sendNotification constructs GcInfo from this data WITHOUT converting the ticks to millis. When the listener gets access to the GcInfo object, a call to getDuration() returns elapsed ticks vs. elapsed millis (contrary to comments in the source code).
因此,您应该使用 JVM 版本 7u51 或更高版本来获取正确的 GC 信息。
关于Java 垃圾收集 GcInfo.getDuration() 将单位从毫秒更改为微秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22344264/
我目前正在处理 com.sun.management.GcInfo 类的一些烦恼。我通过添加 GC 通知监听器改进了我们的服务器日志。每当发生主要 GC 时,我都会记录它所花费的持续时间(以及其他一些
我是一名优秀的程序员,十分优秀!