在发生goroutine泄漏/内存泄漏时,经常需要查看代码中哪一部分goroutine数量过多,可采用以下方法

引入pprof包
import _ "net/http/pprof"
开启http监听服务

func main() {
        go func() {
                log.Println(http.ListenAndServe("localhost:8888", nil))
        }()
}

方法1:
go tool pprof http://1.2.3.4:8888/debug/pprof/goroutine
go笔记-查看golang程序中正在执行的goroutine
输入 pdf 生成goroutine pdf文件

方法2:
curl http://1.2.3.4:8888/debug/pprof/goroutine?debug=1

参考资料:
https://blog.csdn.net/lanyang123456/article/details/106984623

相关文章:

  • 2021-06-13
  • 2022-12-23
  • 2021-05-18
  • 2021-12-24
  • 2022-12-23
  • 2021-12-23
  • 2022-01-12
  • 2021-06-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-28
  • 2021-10-29
相关资源
相似解决方案