使用gin web框架開發,使用 github.com/gin-contrib/pprof 包
import "github.com/gin-contrib/pprof" pprof.Register(router)
輸出圖片相關格式需要先安裝graphviz,graphviz安裝地址如下
https://graphviz.org/download/
web運行起來后,通過命令行執行命令
查看內存使用情況:
go tool pprof http://ip:port/debug/pprof/heap
提醒:如果進入(pprof)模式,輸入web命令,提示錯誤信息為failed to execute dot. Is Graphviz installed? Error: exec: "dot": executable file not found in %PATH%,可能的原因如下:
1. 一個可能是沒有安裝上面的工具
2. 沒有把graphviz/bin目錄配置到path環境變量
3. 如果使用goland等IDE工具打開的terminal,請移步cmd窗口
具體使用:
https://blog.csdn.net/uisoul/article/details/113767329?utm_medium=distribute.wap_relevant.none-task-blog-baidujs_baidulandingword-6
https://blog.csdn.net/skh2015java/article/details/102748222
https://www.jianshu.com/p/ca1aec491c8c
https://www.cnblogs.com/coder-886/p/7541843.html
https://dongshao.blog.csdn.net/article/details/110685058?utm_medium=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control&dist_request_id=371165e7-57ce-478e-a368-b0e1658d1e79&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-BlogCommendFromMachineLearnPai2-1.control
http://liumurong.org/2019/12/gin_pprof/
https://segmentfault.com/a/1190000016412013
https://studygolang.com/articles/12314
https://mp.weixin.qq.com/s/yZUE8N-Qb-AB81DgA1cV_w