Go(lang):如何使用PPROF堆剖析来查找内存泄漏?

huangapple go评论76阅读模式
英文:

Go(lang): How to use PPROF heap profile to find memory leaks?

问题

我正在尝试使用pprof来验证内存泄漏。

有人能解释一下如何阅读在http://localhost:6060/debug/pprof/heap?debug=1找到的堆剖析文件吗?

另外,启动go tool pprof http://localhost:6060/debug/pprof/heap后,输入web命令产生一个空的.svg文件,这正常吗?

非常感谢!

英文:

I am trying to use pprof to verify memory leaks.

Can any explain how to read the heap profile that you find at:
http://localhost:6060/debug/pprof/heap?debug=1

Also, is it normal that by typing the web command after starting go tool pprof http://localhost:6060/debug/pprof/heap it produces an empty .svg file?

Many Thanks

答案1

得分: 4

我可以帮你解答第二个问题。你需要在命令中提供二进制文件的名称:

go tool pprof YOUR_COMPILED_BINARY http://localhost:6060/debug/pprof/heap
英文:

I may help with the second question. You must provide the name of the binary to your command:

go tool pprof YOUR_COMPILED_BINARY http://localhost:6060/debug/pprof/heap

答案2

得分: 1

在这篇英特尔的博客文章中很好地解释了如何阅读堆剖析结果:链接

> 每个条目开头的数字("1: 262144 [4: 376832]")分别表示当前存活对象的数量、存活对象占用的内存量、总分配次数和所有分配占用的内存量。

英文:

How to read the heap-profile is explained pretty good in this intel blogpost:

> The numbers in the beginning of each entry ("1: 262144 [4: 376832]") represent number of currently live objects, amount of memory occupied by live objects, total number of allocations and amount of memory occupied by all allocations, respectively.

huangapple
  • 本文由 发表于 2013年9月30日 01:01:36
  • 转载请务必保留本文链接:https://go.coder-hub.com/19080755.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定