dtzh131555 2015-11-12 20:05
浏览 78
已采纳

Golang分析Appengine测试

I appear to have a memory leak related to receiving large files and sending them to GCS. Trying to use pprof to profile memory usage for my appengine code. My tests use appengine/aetest and I can output the memory profile, but the results don't seem to show me anything useful.

First I made a benchmark. It is a very slow operation, so it only runs once.

$ 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

None of my function calls appear and this 0.5 MB figure is obviously incorrect (I am opening a 12 MB file and uploading it). How do I get the real memory profile?

$ go version
go version go1.3.1 linux/386
$ goapp version
go version go1.4.2 (appengine-1.9.25) linux/386
  • 写回答

1条回答 默认 最新

  • dongqiang5932 2015-11-12 20:19
    关注

    Dug deeper into the testing flags and I found the answer. I needed memprofilerate=1 and alloc_space

    $ goapp test ./cloudstore -memprofilerate=1 -run=none -bench=. -memprofile=cloud.prof
    $ go tool pprof --text --alloc_space cloudstore.test cloud.prof
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题 别拿AI回答
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?