Google app engine Golang剖面appengine测试
我似乎有一个与接收大文件并将其发送到地面军事系统有关的内存泄漏。正在尝试使用pprof分析appengine代码的内存使用情况。我的测试使用appengine/aetest,我可以输出内存配置文件,但结果似乎没有显示任何有用的内容 首先,我做了一个基准。这是一个非常缓慢的操作,因此它只运行一次Google app engine Golang剖面appengine测试,google-app-engine,go,pprof,Google App Engine,Go,Pprof,我似乎有一个与接收大文件并将其发送到地面军事系统有关的内存泄漏。正在尝试使用pprof分析appengine代码的内存使用情况。我的测试使用appengine/aetest,我可以输出内存配置文件,但结果似乎没有显示任何有用的内容 首先,我做了一个基准。这是一个非常缓慢的操作,因此它只运行一次 $ goapp test ./cloudstore -run=none -bench=. -memprofile=cloud.prof BenchmarkLargeFile 1 5
$ goapp test ./cloudstore -run=none -bench=. -memprofile=cloud.prof
BenchmarkLargeFile 1 54124706398 ns/op
$ go tool pprof --text cloudstore.test cloud.prof
Adjusting heap profiles for 1-in-524288 sampling rate
Total: 0.5 MB
0.5 100.0% 100.0% 0.5 100.0% runtime.newG
0.0 0.0% 100.0% 0.5 100.0% allocg
0.0 0.0% 100.0% 0.5 100.0% mcommoninit
0.0 0.0% 100.0% 0.5 100.0% runtime.malg
0.0 0.0% 100.0% 0.5 100.0% runtime.mpreinit
0.0 0.0% 100.0% 0.5 100.0% runtime.rt0_go
0.0 0.0% 100.0% 0.5 100.0% runtime.schedinit
我的函数调用都没有出现,这个0.5MB的数字显然是不正确的(我正在打开一个12MB的文件并上传它)。如何获得真实的内存配置文件
$ go version
go version go1.3.1 linux/386
$ goapp version
go version go1.4.2 (appengine-1.9.25) linux/386
深入研究测试标志,我找到了答案。我需要memprofilerate=1和alloc_空间
$ goapp test ./cloudstore -memprofilerate=1 -run=none -bench=. -memprofile=cloud.prof
$ go tool pprof --text --alloc_space cloudstore.test cloud.prof