【发布时间】:2014-05-12 09:22:13
【问题描述】:
我已经使用 args 启动了一个 Java 应用程序:
"-agentpath:C:\Program Files\jprofiler7\bin\windows-x64\jprofilerti.dll=port=8849,id=134,nowait"
然后控制台显示:
JProfiler> Protocol version 37
JProfiler> Using JVMTI
JProfiler> JVMTI version 1.1 detected.
JProfiler> 64-bit library
JProfiler> Don't wait for frontend to connect.
JProfiler> Using config file C:\Users\user\.jprofiler7\config.xml (id: 134)
JProfiler> Listening on port: 8849.
JProfiler> Instrumenting native methods.
JProfiler> Can retransform classes.
JProfiler> Can retransform any class.
JProfiler> Native library initialized
JProfiler> VM initialized
JProfiler> Using dynamic instrumentation
JProfiler> Time measurement: elapsed time
JProfiler> CPU profiling enabled
JProfiler> Hotspot compiler enabled
然后我现在可以通过 JProfiler GUI 进行连接。
但我需要通过另一个带有 JProfiler API 的 Java 应用程序来连接它。 我怎么能把它连接起来?通过任何 VM 参数?
我只知道也许我必须先创建一个连接,但我不知道如何选择会话 ID。
Connection connection = ConnectionFactory.createRemoteConnection("localhost", 8849, 30);
如果我运行代理应用程序然后首先通过 JProfiler GUI 连接,我可以通过我的 Java 应用程序获取 cpu 信息,包括然后运行我的 JProfiler API 应用程序。
Profiling data :
Hot spots:
Top 5 hot spots:
Hot spot 1: ProfilerTest.main(java.lang.String[ ]): 34 ms (100 %)
Backtraces:
ProfilerTest.main(java.lang.String[ ]): 34722 (0)
***: 34722 (0)
Cpu tree:
***: 34722 (0)
ProfilerTest.main(java.lang.String[ ]): 34722 (0)
java.util.Scanner.next(): 34722 (0)
但如果我先运行代理应用程序然后通过我的 JProfiler API 应用程序连接,我将一无所获。
Profiling data :
Hot spots:
Top 5 hot spots:
Cpu tree:
***: 0 (0)
【问题讨论】:
标签: jprofiler