link the pprof http handler by adding the following line into your program(usually the main file):
import _ "net/http/pprof"
Then you can easier grab head profile(understand how the memory is consumed) by using the commands below:
go tool pprof http://localhost:6060/debug/pprof/heap
Or to look at a 30-second CPU profile:
go tool pprof http://localhost:6060/debug/pprof/profile
Or to view all available profiles:
go tool pprof http://localhost:6060/debug/pprof/
For more information on how the understand the pprof output, you can go to Profiling Go Programs or the homepage of google perf tools.
BTW: since there pprof handlers are so convenient, it is generally a good practice to start a debug http server with pprof enabled even if the program is not going to serve any http traffic.
No comments:
Post a Comment