12月 16

[转载]golang pprof

https://blog.wolfogre.com/posts/go-ppof-practice/

<code>_ "net/http/pprof" // 引入 pprof 模块
//  主函数内存分析
go func() {
	http.ListenAndServe("0.0.0.0:8090", nil)
}()</code>
<code>//命令行,收集cpu 如果生成svg 和图片安装 graphviz 
// top list 定位问题
go tool pprof http://localhost:8090/debug/pprof/profile
// 收集内存
go tool pprof http://localhost:8090/debug/pprof/heap
// 内存回收
go tool pprof http://localhost:8090/debug/pprof/allocs</code>