1. 使用btrace前需要配置下环境变量.
Btrace_Path
%Btrace_Path%\bin
2. Btrace 跟visual vm 一样,不支持JDK5. 所以我维护的老项目又悲剧了.迄今为止能profiling jdk 5 的也只有jproflier.
explanation from Bachorik.
JRE 5 lacks the ability to dynamically attach to a running JVM process, load the agent and retransform classes. Additional, it requires the agent to be in form of a native library incurring rather big overhead in maintaining multiplatformness
http://kenai.com/projects/btrace/forums/forum/topics/13112-running-BTrace-on-JRE
3. 配置好JRE后,使用JPS获取需要监控的PID. JPS可以在%java_home%/bin目录下找到.
4. Btrace解压文件Sample目录下有很多sample 程序, 多半需求根据名字直接用. 比如检测method cpu,memory 的 utilization.
5. OSGI的工程需要在配置文件里面把Btrace的library include进去.
config.properties
org.osgi.framework.bootdelegation=com.sun.btrace, com.sun.btrace.*
一些常用的code:
Profiling:
Error : Port 2020 unavailable.
Step1:netstat -np TCP | find "2020" {
netstat -np <protocol> | find "port #"}
Step2:btrace –p new port …..
http://kenai.com/jira/browse/BTRACE-31
official website:
http://kenai.com/projects/btrace
download :
http://kenai.com/projects/btrace/downloads/directory/releases
Manual:
http://kenai.com/projects/btrace/pages/UserGuide
JavaDoc1.2: