分析每个类垃圾回收对象实例的数量 [英] Profiling number of garbage-collected object instances per class
问题描述
我正在寻找一种工具,可以提供类似于VisuaVM的关于活动对象的分析,但是处于非GUI模式。
我所指的Visual VM功能,通过转到Profiler选项卡并单击Memory来访问。
通过为每个对象设置Profile对象分配和GC对象)。这给了我在自动刷新视图中所需要的东西,我可以为感兴趣的类进行过滤。
但是,我希望能够导出将活动对象表格复制到文本文件中,以获取每个快照(Visual VM每隔一秒刷新一次)。显然,指向和点击不可能是一个解决方案......
任何人都知道这样的命令行探查器?
我一直在寻找提供堆转储的jmap,但它太昂贵了(转储需要很长时间,我只对对象数量感兴趣)。
有一种称为YourKit的商业工具,但我不知道它是否可以做我所需要的(对于我需要的一次性使用类型而言,这似乎相当昂贵)。
如果我现在可以使用VisualVM,但是它将输出附加到文件中(而不是刷新它的GUI),它会是完美的...
我认为类直方图是您所期待的。您可以定期收集直方图,这会显示每个类的对象数量和占用空间。然后,您可以自己分析文本输出以便:
使用 jmap -histo $ pid收集类别直方图。
I am looking for a tool that can provide VisuaVM-like profiling about live objects, but in non-GUI mode.
The Visual VM functionality I am referring, is accessed by going to the "Profiler" tab and clicking "Memory".
By setting a profile preset of "Profile object allocations and GC" for ever 1 objects (all objects). This gives me exactly what I need in an auto-refreshing view, which I can filter for the class that interests me.
However, I want to be able to export the table of "live objects" to a text file, for every snapshot that is taken (Visual VM refreshes every one seconds). Obviously, pointing and clicking cannot possibly be a solution...
Anyone know of such a "command-line" profiler?
I have been looking at jmap which provides heap dumps, but it is too costly (the dump takes too long, I am just interested in the number of objects).
There is a commercial tool called YourKit but I don't know whether it can do what I need (and also seems rather expensive for the type of "one-off" usage I need it for).
If I could use VisualVM as-is, but have it append the output to a file (instead of refreshing its GUI) it'd be perfect...
I think Class Histograms are what you look for. You could collect the histograms in regular intervals and this will show you number of objects of each class and occupied space. You can then parse the text output yourself in order to:
- compare two histograms to see instance allocation/deallocation
- filter by a class name
- monitor space occupation of class instances over time
Collect class histogram with jmap -histo $pid.
这篇关于分析每个类垃圾回收对象实例的数量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!