Go pprof:遇到错误,无法识别的配置文件格式。

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

Go pprof: Got Error unrecognized profile format

问题

我正在使用Go revel框架(我的Go版本是1.6.2)开发一个Web程序。我在内存使用方面遇到了问题。Revel占用的内存每天几乎增加了几百MB。因此,我想对程序进行调优。然后我学习了如何使用go pprof,并按照github.com/revel/modules/tree/master/pprof中所说使用了revel pprof。但是,当我尝试使用以下命令获取内存分析时:

go tool pprof http://sit:9000/debug/pprof/heap.

它报错说无法识别的分析格式。你可以看到下面的截图。

enter image description here
我已经为这个问题苦苦挣扎了几个小时。非常感谢你提供的任何帮助!提前谢谢!

英文:

I'm developing a web program with Go revel framework(my go version is 1.6.2). And I got issues with the memory usage. The memory occupied by revel is increasing almost hundreds of MB every day. So I want to tune the program. Then I learn to use the go pprof and use the revel pprof as said in github.com/revel/modules/tree/master/pprof. But while I'm trying to get the memory profile with following command

> go tool pprof http://sit:9000/debug/pprof/heap.

It got error unrecognized profile format. You can see as following snapshot.

enter image description here
I've struggled on this issue for hours. Any help is appreciated! Thank you in advance!

答案1

得分: 1

很可能是因为你的调试配置文件是空的。
你需要使用SetBlockProfileRate函数来指定应用程序的分析频率。

https://golang.org/pkg/runtime/#SetBlockProfileRate

只需在你的main文件中导入runtime包,并调用runtime.SetBlockProfileRate函数。

或者,你可以使用这个包,它会为你处理一些默认设置:https://github.com/pkg/profile

英文:

It's most likely because your debug profile is empty.
You need to specify how often to profile the app using SetBlockProfileRate

https://golang.org/pkg/runtime/#SetBlockProfileRate

Just import the runtime package in your main file and call the runtime.SetBlockProfileRate function.

Alternatively, you can use this package, which handles it for you, with some defaults: https://github.com/pkg/profile

huangapple
  • 本文由 发表于 2016年12月28日 17:25:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/41359022.html
匿名

发表评论

匿名网友

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

确定