英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论