是否可以在 jvisualvm 中同时进行 CPU 和内存分析?
我有一个运行相当长的分析(大量数字运算)的应用程序,因此运行该应用程序一次大约需要 3-4 小时,充分利用所有核心。现在我很确定我的代码不是无懈可击的,所以我想分析并寻找潜在的弱点。
我在 jvisualvm 上读了很多书,也玩了一下。然而,它似乎是选择 CPU 或内存分析,而本文 有一段有趣的引述,作者说:
我意识到 CPU 和内存分析可以同时完成,但出于本文的目的,我想将它们分开。
有人能否认或证实这一点吗?如果这是可能的,它将非常有用,所以我不会一遍又一遍地以不同的模式进行分析。如果不可能,是否可以排队进行不同的分析分析,以便我可以过夜运行它们?
谢谢,
I have an application which runs a rather long analysis (lots of number crunching) so running the application once takes about 3-4 hours, fully utilizing all of the cores. Now I am pretty sure my code is not water-tight so I want to profile and look for potential weak points.
I have been reading quite a bit on jvisualvm, and played around with it a bit too. However it appears as one chooses either cpu or memory profiling, while this article from Javalobby has an interesting quote where the author says:
I realise that both the CPU and Memory Profiling could have been done simultaneously, but for the purpose of this article I wanted to keep them seperate.
Could anyone deny or confirm this? If this is possible it would very useful, so I don't start over and over to profile in different modes. If it's not possible, would it be possible to queue to different profiling analyses so I can run them overnight?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不可能同时进行 CPU 和内存分析,但您可以非常轻松地在 CPU 和内存之间切换,尤其是在使用“采样器”选项卡时。对于你的情况,我会从简单的监控开始。通过查看图表,您应该能够判断自己是否有内存问题。如果您有内存问题,我会先尝试修复它,然后将您的注意力转移到 CPU 分析上。
It is not possible to do CPU and Memory profiling together, but you can switch between CPU and memory very easily especially when using 'Sampler' tab. For your case, I would start with just simple monitoring. Looking at the graphs, you should be able to tell, if you have memory problem or not. If you have memory problem, I would try to fix it first and that turn your attention to the CPU profiling.
我发现分析器往往会低估对象分配的成本,因此我通常使用 cpu 分析来启用内存分析,因为我觉得这会提供更真实的 CPU 分析结果。 (即使我不查看内存分析报告)
如果有疑问,我建议您运行 CPU 配置文件,无论有没有内存分析,您都可以获得非常不同的结果。根据我的经验,这两个结果都值得优化。 ;)
顺便说一句:我使用 YourKit,但我不认为 VisualVM 在这方面有很大不同。
I find that profilers tend to underestimate the cost of object allocation, so I usually enable memory profiling with cpu profiling, as I feel this gives a more realistic CPU profiling result. (Even if I don't look at the memory profiling report)
If in doubt I suggest you run the CPU profile, with and without memory profiling and you can get very different results. In my experience it is worth optimising for both results. ;)
BTW: I use YourKit, but I don't imagine VisualVM to be very different in this regard.