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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求京东批量付款能替代天诚
  • ¥15 slaris 系统断电后,重新开机后一直自动重启
  • ¥15 51寻迹小车定点寻迹
  • ¥15 谁能帮我看看这拒稿理由啥意思啊阿啊
  • ¥15 关于vue2中methods使用call修改this指向的问题
  • ¥15 idea自动补全键位冲突
  • ¥15 请教一下写代码,代码好难
  • ¥15 iis10中如何阻止别人网站重定向到我的网站
  • ¥15 滑块验证码移动速度不一致问题
  • ¥15 Utunbu中vscode下cern root工作台中写的程序root的头文件无法包含