苹果牛

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

1.  JPS 获取 PID –> jstack <optional>PID.

    -F  to force a thread dump. Use when jstack <pid> does not respond (process is hung)
    -m  to print both java and native frames (mixed mode)
    -l   long listing. Prints additional information about locks

eg.

jstack –l 2134 > "c:\threadlog.tdump", 存成tdump便于使用TDA进行分析. 在visual vm 装个插件打开就可以用了.

 

Untitled

 

 

2. Visual VM

如果profiling remote jvm,需要在jvm configure里面加

-Dcom.sun.management.jmxremote.port=3333     
-Dcom.sun.management.jmxremote.ssl=false 
   -Dcom.sun.management.jmxremote.authenticate=false 

http://docs.oracle.com/javase/6/docs/technotes/guides/visualvm/jmx_connections.html

 

Untitled

3. Btrace, 自带Sample里面的代码 ,这个感觉不太好用.

@BTrace
public class JStack {
    static {
        deadlocks(false);
        jstackAll();
        exit(0);
    }
}

ps : 忘记了,自带的jconsole也可以看. local 还是用visual vm 分析起来比较方便. Production用jstack命令. Trigger 倒是很简单,怎么分析是关键.

posted on 2012-12-20 15:44  苹果牛  阅读(1706)  评论(0编辑  收藏  举报