如何生成 Java 对象生命周期的直方图
我有一个 Tomcat Java Web 应用程序,它在加载时会破坏 Java GC。我认为这是由于大量寿命较短的对象与未知数量的中等寿命对象的组合所致。
为了验证这个理论,我想找到一个工具,它可以让我确定所有分配对象的对象生命周期(或每 10 个对象等以获得更好的性能)。理想情况下,最终输出将是一个直方图,显示存活不同时间的对象的相对数量。
我认为这个工具可能会构建在 Instrumentation API 或 JVMTI 之上。如果没有好的工具已经可以做到这一点,我也希望得到有关在编写此类工具时最好使用哪些 JVM 接口的建议。
I have a Tomcat Java webapp which is thrashing the Java GC when under load. I think this is due to a combination of a large amount of short lived objects along with an unknown amount of moderately long lived objects.
To validate this theory I want to find a tool which will let me determine the object lifetimes for all allocated objects (or every 10th object etc for better performance). Ideally the final output will be a histogram showing the relative number of objects which live for different amounts of time.
I think this tool will likely be built on top of either the Instrumentation API or the JVMTI. If there are no good tools which already do this I would also appreciate suggestions about which of the JVM's interfaces would be best to use when writing such a tool.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我现在开始编写一个工具来完成我最初要求的事情。当前代码可以在这里找到:
http://wiki.github.com/mchr3k/org .inmemprofiler/
到目前为止,我已经成功地按实例计数获取了所有对象分配的文本直方图。这不包括以不同方式处理的数组分配。
我现在正在努力添加实例大小信息以及使用 JVMTI 跟踪数组分配。
I have now started writing a tool to do what I originally asked about. The current code can be found here:
http://wiki.github.com/mchr3k/org.inmemprofiler/
So far I have managed to get a textual histogram of all object allocations by instance count. This does not include array allocations which are handled differently.
I am now working on adding instance size information along with tracking of array allocations by using the JVMTI.