-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
Description
pprof
基本使用
查看堆栈调用信息
$ go tool pprof http://localhost:6060/debug/pprof/heap查看协程信息
$ go tool pprof http://localhost:6060/debug/pprof/goroutine查看30s内的 CPU 信息
$ go tool pprof http://localhost:6060/debug/pprof/profile?seconds=30其他
$ go tool pprof http://localhost:6060/debug/pprof/threadcreate
$ go tool pprof http://localhost:6060/debug/pprof/block
$ go tool pprof http://localhost:6060/debug/pprof/mutex
$ go tool pprof http://localhost:6060/debug/pprof/trace?seconds=5扩展使用
排查 golang 程序内存泄露.
获取 A 时间点的堆栈 profile
$ curl -s http://localhost:6060/debug/pprof/heap > A.heap过一段时间后,内存开始泄露了,再获取 B 时间点的堆栈 profile
$ curl -s http://localhost:6060/debug/pprof/heap > B.heap比较 A, B 时间点的堆栈差异
$ go tool pprof --base A.heap B.heap使用 web 命令生成一个 SVG 文件
(pprof) web或者直接打开 web 界面
$ go tool pprof --http :9090 --base B.heap A.heap
生成图表,需要安装 Graphviz
参考
Profiling Go programs with pprof
Hi, 使用多年的go pprof检查内存泄漏的方法居然是错的