是否可以监控“Full GC”? JMX 中的频率(在 HotSpot 上)?
我想监控 JMX 中的 Full GC 频率。 MBean 公开 GC 计数。 (参见 http://download. oracle.com/javase/1.5.0/docs/api/java/lang/management/GarbageCollectorMXBean.html - java.lang:type=GarbageCollector,name=)。
问题是MBean 不区分minor GC 和full gc。
有人有主意吗?
谢谢。
阿尔诺
I want to monitor Full GC frequency in JMX. A MBean exposes GC count.
(cf. http://download.oracle.com/javase/1.5.0/docs/api/java/lang/management/GarbageCollectorMXBean.html - java.lang:type=GarbageCollector,name=).
The problem is that MBean does not distinguish between minor and full gc.
Does someone have an idea ?
Thanks.
Arnault
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我对此并不完全确定,但我假设控制所有内存池(至少是老一代的内存池)的垃圾收集器是用于主要GC的垃圾收集器。例如:我有一个 JVM 与这 2 个收集器一起运行:
内存
考虑到这一点我想说,PS Scavenge 用于minor gc,PS MarkSweep 用于major gc。
更新(基于 @ajeanson 评论,顺便说一句,感谢您的反馈):
实际上,我放在那里的示例取自我正在使用的 JVM 的 MXBeans 中公开的信息。正如您所提到的,这些是 GC 算法,GC 的 MXBean 使用的名称基于 GC 使用的算法。我一直在寻找有关此的更多信息;在本文中 http://download.oracle.com/ javase/6/docs/technotes/guides/management/jconsole.html,内容如下:
看一下 MXBean 上的 collectionCount 属性,在我的“PS MarkSweep”收集器(管理老一代池的收集器)的情况下,收集计数似乎仅当我在详细输出中获得完整 GC 时才会增加。我可能是错的,也许在某些情况下这个收集器也执行小型 GC,但我需要运行更多测试才能完全确定这一点。
如果有人发现了其他问题,或者您有关于此问题的更多具体信息,请告诉我,因为我对此非常感兴趣。
I'm not completely sure about this but I assume that the garbage collector that controls all the memory pools (at least the one for Old Gen) is the one used for major gc. e.g.: I have a JVM running with these 2 collectors:
Taking this into account I would say, PS Scavenge is used for minor gc and PS MarkSweep for major gc.
UPDATE (based on @ajeanson comment, thanks for your feedback btw):
Effectively, the example I put in there was taken from the information exposed in the MXBeans of the JVM I was using. As you mentioned, these are GC algorithms, and the name the MXBean for the GC is using is based on the algorithm the GC is using. I've been looking for some more information about this; in this article http://download.oracle.com/javase/6/docs/technotes/guides/management/jconsole.html, reads the following:
Taking a look at the collectionCount property on the MXBeans, in the case of my "PS MarkSweep" collector (the one managing the Old Generation pool), the collection count seems to increase only when I get a full GC in the verbose output. I might be wrong and maybe in some cases this Collector performs also minor GC, but I would need to run more tests to be totally sure about this.
Please, let me know if someone finds out something else or you have some more specific information about this issue as I'm quite interested in it.
它确实...看看名称,例如 ParNew、ConcurrentMarkSweep 等。
有些名称用于minor gc,有些用于full gc,
it does ... have a look to the names e.g. ParNew, ConcurrentMarkSweep, .. etc.
some names are for minor gc, some for full gc,
正在寻找相同的信息,并在阅读 https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BABFAFAE 对于 JAVA 8,某些收集器可用于 Minor/Full GC(例如G1 或 SerialGC),但其他一些收集器仅用于次要或完整 GC(例如 ParNewGC、ConcMarkSweepGC)。
例如,当您使用 G1 时,所使用的两个收集器的名称非常明确,用于完整 gc 的收集器是 G1 老一代。
但是,因为 MXBean 缺少有关次要或完整的信息,要么:
,我将只打印收集器名称以及时间和计数值,然后让读取这些数据的人进行分析。就我而言,数据将被绘制成图表(Grafana)
不确定最新的 JDK 是否改进了这一点......
Was looking for the same information and found out after reading https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html#BABFAFAE for JAVA 8 that some collectors can be used for both minor/full GCs (such as G1 or SerialGC) but some other collectors are for only minor or full GCs (such as ParNewGC, ConcMarkSweepGC).
And when you use the G1 for example, the two collectors used are quite explicit with their names and the one for full gc is the G1 Old Generation.
But, because the MXBean is missing the information about being minor or full, either:
I will, in my case, just print the collector name along with the time and count value and let the person reading those data make the analysis. In my case, the data will be graphed (Grafana)
Not sure if the newest JDK improve this...