Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save YorkHwang/77eb35cde013a6df10b1b627cfee182e to your computer and use it in GitHub Desktop.
Save YorkHwang/77eb35cde013a6df10b1b627cfee182e to your computer and use it in GitHub Desktop.
内存泄露排查:
1.找到PID: ps -ef|grep '[进程名关键字]'
2.间隔打印当前GC情况:jstat -gcutil [PID] [间隔打印的毫秒数]
3.查看当前内存排名前20的对象实例:jmap -histo:live [PID]|head -20
4.如果不明确,下载内存dump文件:jmap -dump:live,format=b,file=[path+fileName.hprof] [PID]
5.MAT工具(https://www.eclipse.org/mat/downloads.php)分析dump文件,关注泄露点:Leaks,查看内存占比
CPU消耗排查:
1.找到PID: ps -ef|grep '[进程名关键字]'
2.找到进程PID消耗cpu最多的线程:TID: ps -Lfp [PID] 或者 top -Hp [PID]
3.TID线程ID转换为16进制 XTID:printf "%x\n" [TID]
4.jstack [PID] | grep -C[显示上下行数] [XTID] >jstack.log ,可以基本定位消耗CPU的类和方法
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment