golang中协程泄漏检测-pprof(内置包)
作者:互联网
代码案例
package main
import (
"fmt"
"net/http"
_ "net/http/pprof"
)
func main(){
for i := 0; i < 5; i++ {
go func() {
select {
default:
return
}
}()
}
go func() { select {} }() // 泄漏协程
if err := http.ListenAndServe(":8080", nil); err != nil {
fmt.Println("start pprof failed")
}
}
web查看协程泄漏信息
http://127.0.0.1:8080/debug/pprof/goroutine?debug=2
http://127.0.0.1:8080/debug/pprof/goroutine?debug=1
参考文档
标签:golang,http,泄漏,pprof,中协程,func,debug,8080 来源: https://www.cnblogs.com/mayanan/p/15842376.html