使用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