在主函数中引入包 _ "net/http/pprof" //debug

在main方法里加入

//debug
go func() {
_ = http.ListenAndServe("0.0.0.0:6060", nil)
}()
go tool pprof -alloc_space -cum -svg http://127.0.0.1:6060/debug/pprof/heap

> heap.svg

即可弄到内存数据分析图片 用浏览器打开即可