Gin pprof性能分析

December 28, 2020

pprof

// 导入包
import (
  "github.com/DeanThompson/ginpprof"
)


// gin框架直接集成
router := gin.New()
ginpprof.Wrapper(router)

命令行分析

$ go tool pprof http://localhost:6060/debug/pprof/heap
Fetching profile over HTTP from http://localhost:6060/debug/pprof/heap
Saved profile in /Users/root/pprof/pprof.alloc_objects.alloc_space.inuse_objects.inuse_space.008.pb.gz
Type: inuse_space
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top10
(pprof) topShowing nodes accounting for 837.48MB, 100% of 837.48MB total      flat  flat%   sum%        cum   cum%  837.48MB   100%   100%   837.48MB   100%  main.main.func1

top命令查看当前内存使用情况

隔段时间继续使用此命令查看看是否有内存持续增长的数据。

参考

https://segmentfault.com/a/1190000016412013

https://eddycjy.gitbook.io/golang/di-9-ke-gong-ju/go-tool-pprof#qian-yan

Go内存泄漏

IARNO

服务端开发

too many open files 问题定位

Go grpc案例