添加配置
import _ "net/http/pprof"
go func() {
http.ListenAndServe("127.0.0.1:6060", nil)
}()
获取堆栈
curl http://127.0.0.1:6060/debug/pprof/heap >heap.out
安装graphviz
apt-get install -y graphviz
生成热力图
go tool pprof -http=0.0.0.0:8080 heap.out
打开浏览器
参考文章
https://blog.csdn.net/winfield821/article/details/104186306