-
Modify it in main.go to:
package main
import (
"net/http"
_ "net/http/pprof"
"xxxxxxx"
)
func main() {
go func() {
http.ListenAndServe("0.0.0.0:8081", nil)
}()
xxxxx.Run()
}
-
View the files of this http service online:
http://localhost:8081/debug/pprof/
Document description:
/debug/pprof/profile: Visiting this link will automatically perform CPU profiling for 30s, and generate a file for download
/debug/pprof/allocs: allocated memory statistics
/debug/pprof/heap: the path of Memory Profiling, accessing this link will get a file of memory profiling results
/debug/pprof/block: Path to block Profiling
/debug/pprof/goroutines: list of running goroutines, and call relationship
-
Check out the web interface:
go tool pprof http://127.0.0.1:8081/debug/pprof/heap
pprof: web
go tool pprof http://127.0.0.1:8081/debug/pprof/goroutine
pprof: web