如何在 Java WebStart (JNLP) 应用程序中获取多个 hprof 转储?
使用 Java 控制台应用程序,我可以执行以下操作:
java -agentlib:hprof=heap=dump,format=b MyClass
然后,每当我想要拍摄堆快照以供以后分析时,我都可以按 ctrl-\(或在 Windows 上按 ctrl-break)。
我想对 Java Web Start 应用程序做同样的事情,但我似乎无法让它工作。 我可以使用 JAVAWS_VM_ARGS 环境变量传入 agentlib 参数,但在控制台中输入 ctrl-\ 和 ctrl-break 似乎没有执行任何操作。 当程序启动时,我得到的只是一个转储,这并不是很有趣,因为那时我什至还没有登录到我们的程序并执行我想要分析的事务。
Working with a Java console application, I can do this:
java -agentlib:hprof=heap=dump,format=b MyClass
Then I can hit ctrl-\ (or ctrl-break on Windows) any time I would like to take a snapshot of the heap for later analysis.
I would like to do the same thing for a Java Web Start application, but I cannot seem to get that to work. I can pass in the agentlib argument with the JAVAWS_VM_ARGS environment variable, but entering ctrl-\ and ctrl-break in the console doesn't seem to do anything. All I get is one dump, when the program starts, which isn't really interesting since at that point I haven't even logged into our program yet and executed the transactions I want to analyze.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用以下 JMV 参数启动您的应用程序,以启用 JMX 并在端口 9004 上启动侦听器:
然后看一下这个 Java 程序,它可以连接到 JMX 服务器并按需进行堆转储。 源代码包含注释以及互联网上两篇有用文章的链接,这些文章帮助我完成了所有这些工作。 祝你好运 !
链接: JmxHeapDumper.java
PS 显然让 JMX 启动 WebStart 应用程序很棘手,我发现了这个讨论,希望它有所帮助:http://forums.java.net/jive/message.jspa?messageID=311717
Start your application with the following JMV arguments to enable JMX and boot a listener on port 9004:
Then have a look at this Java program which can make a connection to the JMX server and take a heap dump on demand. The source code includes comments with links to 2 useful articles on the internet that helped me get all of this working. Good luck !
Link: JmxHeapDumper.java
P.S. apparently getting JMX to start for a WebStart app is tricky, I found this discussion, hope it helps: http://forums.java.net/jive/message.jspa?messageID=311717
您可以使用 VisualVM 从正在运行的应用程序中获取堆转储。 VisualVM 允许您浏览和保存堆转储。
You could use VisualVM to take heap dumps from the running application. VisualVM lets you browse and save the heap dumps.