如何使用 VisualVM 分析应用程序启动

发布于 2024-10-07 03:51:22 字数 272 浏览 0 评论 0原文

据我所知,您只能分析正在运行的使用 VisualVM 的应用程序

有谁知道使用 VisualVM 来分析 java 应用程序的启动和启动的方法吗?

我坚信一定有办法,否则就是重大疏忽。

希望我只是误读了文档。

谢谢,p。

As far as i can tell, you can only profile a running application using VisualVM.

Does anyone know of a way to profile the launch and startup of a java application using VisualVM?

I'm convinced there must be a way, otherwise it would be a major oversight.

Hoping I've just misread the documentation.

Thanks, p.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

惜醉颜 2024-10-14 03:51:22

使用 eclipse 启动器,并在 main 方法中的适当位置设置断点。

然后,以调试模式启动,在 VisualVM 中启用分析,然后继续使用 Eclipse。

这不会分析类加载之类的东西,但对我来说已经足够了。

Use the eclipse launcher, and set a breakpoint at an appropriate place in the main method.

Then, start in debug mode, enable profiling in visualVM, and then resume using eclipse.

That won't profile class loading and stuff, but it's good enough for me.

病女 2024-10-14 03:51:22

您是否使用“-Xrunjdwp”命令行选项设置分析?如果是这样,该选项具有 "suspend" 参数 仅用于此目的:

如果要在加载主类之前立即挂起目标 VM,则为 True;否则为假。

我自己的配置示例:

-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

我将其与 YourKit 分析器一起使用,但我认为原理是相同的。

Are you setting up the profiling using the `-Xrunjdwp" command-line option? If so, that option has a "suspend" parameter for just this purpose:

True if the target VM is to be suspended immediately before the main class is loaded; false otherwise.

Example from my own config:

-Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

I use this with the YourKit profiler, but I think the principle is the same.

往事随风而去 2024-10-14 03:51:22

我发现启动分析器很有帮助:

VisualVM 1.3.6 的启动分析器插件启用了检测
从本地 Java 5+ 应用程序启动开始对其进行分析。这也是
在分析短期运行的流程时很有帮助。

I found Startup Profiler helpful:

Startup Profiler plugin for VisualVM 1.3.6 enables instrumented
profiling of local Java 5+ applications from their startup. It is also
helpful when profiling short-running processes.

旧情勿念 2024-10-14 03:51:22

两种常见的 Java 开发环境 (NetBeans/Eclipse) 都支持直接使用附加的 VisualVM 执行应用程序。如果是 Eclipse,则必须安装 插件。对于 NetBeans,据我所知,该支持已经集成。
即使没有源,您仍然可以通过这两个环境运行 JAR 文件,从而启动与 VisualVM 连接的应用程序。

Both common Java development environments (NetBeans/Eclipse) support application execution directly with attached VisualVM. In case of Eclipse you have to install a plugin. In case of NetBeans the support is AFAIK already integrated.
Even if do not have the sources you can still run the JAR file(s) via both environments and therefore start your app connected with VisualVM.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文