*注意在教程上提到过windows vista 7下可能存在权限问题,最好就是右击,run as admin,如果出现一个cmd
窗口,什么都没有但没有消失那就是说明成功了,如果出现诸如
[java] Error occurred during initialization of VM
[java] Could not find agent library on the library path or in the local dir
ectory: JPIBootLoader
那就是路径配置错误,一闪消失,应该是权限的问题
Using the Java Profiler with Java 1.4 (or lower) Virtual Machines
tptp对于jdk1.5之前与之后再agentControl上还是很有区别的,重点说JDK1.5后
Using the Java Profiler with Java 1.5 (or higher) Virtual Machines
1.agentlib:JPIBootLoader=JPIAgent[:[help]|[<option>=<value>,...]];<profiler>[:<option>=<value>,...]
这个是启动jvm时的参数,具体意义教程均有说明
server=[standalone | enabled | controlled]
standalone 独立模式,在这个模式下,eclipse是没有用的,所有参数均在命令行中,检测结束后,会有一个trace.trcxml文件,导入eclipse(file-import-profiling and logging-profiling file)后即可分析,查看(也就是说他是静态的)The profiling agent runs in a headless mode, which means it is not possible to interact with it from the workbench. Configuration information is provided as part of the command lineand profiling data is stored in a file directly by the profiling agent. The profiling file can then be imported into the workbench at a later date.
The Java Profiling Agent is manually attached to a JVM instance and generates profiling data to an output file. The default output file is called trace.trcxml, but you can specify a different file name using the file= filename parameter. When this option is selected, the Java Profiling Agent produces an enclosing traceRoot element to form a complete and valid XML document. enabled (This is the default.)这个最常用,在命令行中执行后,立马到eclipse中,在profiling configuration选项卡中找到 Attach to Agent,在agent control选项卡中便可以看到正在运行的agent了。 注意,此时可以在EDIT OPTIONS中设置监控的类型等参数!
另外,需要注意的是,很多人说tptp监控tomcat等很慢,这个问题,一方面的确是tptp的原因,但是最重要的是,他们没有设置过滤,监控了所有的包,尤其是在standalone模式下,如果没有配置filters.txt那么所有的包都监控,机子的内存很快就会不行!
所以,一定要合适配置要监控的包,其他的全部exclude掉!The profiling agent runs in the background of the JVM without consuming resources until it is connected to by the workbench and asked to start monitoring. Data is then streamed over the agent's data channel and consumed by the workbench. This mode allows the application to run normally, but produces no profiling data until a client attaches to the agent to give it instructions. When this option is selected, the Java Profiling Agent produces only XML fragments instead of a complete XML document. controlled 这个和enable差不多The profiling agent preempts the JVM from initialization (the agent is loaded but it blocks the application from running) until it is attached to from the workbench and given instructions to start monitoring by a client. That is, when the profiling agent is launched in controlled mode, it will appear to hang the JVM until asked to start monitoring and it will produce only XML fragments instead of a complete XML document.
以下是我的启动脚本,注意Xmx Xms XX:MaxPermSize这些参数试具体情况而定 写道
java -Xmx1G -Xms512M -XX:MaxPermSize=512M -agentlib:JPIBootLoader=JPIAgent:server=standalone,filters=filters.txt;CGProf -classpath C:\test\liferay-portal-6.0.5\tomcat-6.0.26\bin\bootstrap.jar -Dcatalina.home=C:\test\liferay-portal-6.0.5\tomcat-6.0.26 -Dcatalina.base=C:\test\liferay-portal-6.0.5\tomcat-6.0.26 org.apache.catalina.startup.Bootstrap -config C:\test\liferay-portal-6.0.5\tomcat-6.0.26\conf\server.xml start
filters.txt
com.company.* * INCLUDE
org.springframework.* * EXCLUDE
* * EXCLUDE