- 开启监听
package main
import (
"net/http"
_ "net/http/pprof"
)
func main() {
http.ListenAndServe(":6060", nil)
}
- 命令行
# 查看内存
go tool pprof -inuse_space http://localhost:6060/debug/pprof/heap
# 查看goroutine
go tool pprof http://localhost:6060/debug/pprof/goroutine
# 下载goroutine详情
wget http://localhost:6060/debug/pprof/goroutine?debug=1 -O debug.html
wget http://localhost:6060/debug/pprof/goroutine?debug=2 -O debug2.html
# pprof内部命令
top
list
traces