golang pprof 内存分析
use pprof to get applicationmemoryuseageadd code in your main funciton
import ("log" _
"net/http/pprof"
)
func main() {
go func() {
log.Println(http.ListenAndServe(
"localhost:6060", nil)) }()
}
build and compile you application.
let application run and send requestthen run
#getmemory useage
go tool pprof
-inuse_space http://127.0.0.1:6060/debug/pprof/heap
go tool pprof .
/yourbinarynamelocalhost:6060/debug/pprof/profile
your can use help ,ortop N to get topmemory use function .
use "svg"or "web"to printdetail information .and need graphviz
sudo yuminstall -y graphviz
or mac
brew install graphviz
if not generate svg ,downtar file anduse this command to get svg,after you canopen svg inbrowser :
go tool pprof/Downloads/mv-w.1/pprof.xxx.localhost:6060.samples.cpu.001.pb
页:
[1]