Go pprof in Practice
Go pprof in Practice Bomb program package main import ( // omitted _ "net/http/pprof" // auto-register handlers to the HTTP server for profiling via HTTP // omitted ) func main() { // omitted runtime.GOMAXPROCS(1) // limit CPU usage to avoid overload runtime.SetMutexProfileFraction(1) // enable lock contention profiling runtime.SetBlockProfileRate(1) // enable blocking operation profiling go func() { // start an HTTP server; pprof handlers have already been registered // /debug/pprof/ if err := http.ListenAndServe(":6060", nil); err != nil { log.Fatal(err) } os.Exit(0) }() // omitted } http://localhost:6060/debug/pprof/ Type Description Notes allocs Samples of memory allocations Can open in a browser, but readability is low blocks Samples of blocking operations Can open in a browser, but readability is low cmdline Show program startup command/args Can open in a browser; shows ./go-pprof-practice goroutine Stacks of all current goroutines Can open in a browser, but readability is low heap Samples of heap memory usage Can open in a browser, but readability is low mutex Samples of lock contention Can open in a browser, but readability is low profile Samples of CPU usage Opening in a browser downloads a file threadcreate Samples of system thread creation Can open in a browser, but readability is low trace Program execution traces Opening in a browser downloads a file; not covered here, see Go trace Investigate high CPU usage