我似乎有與接收大文件并將它們發送到 GCS 相關的內存泄漏。嘗試使用 pprof 來分析我的 appengine 代碼的內存使用情況。我的測試使用 appengine/aetest,我可以輸出內存配置文件,但結果似乎沒有顯示任何有用的信息。首先我做了一個基準。這是一個非常慢的操作,所以它只運行一次。$ goapp test ./cloudstore -run=none -bench=. -memprofile=cloud.profBenchmarkLargeFile 1 54124706398 ns/op$ go tool pprof --text cloudstore.test cloud.prof Adjusting heap profiles for 1-in-524288 sampling rateTotal: 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.5 MB 的數字顯然是不正確的(我正在打開一個 12 MB 的文件并上傳它)。我如何獲得真實的內存配置文件?$ go versiongo version go1.3.1 linux/386$ goapp versiongo version go1.4.2 (appengine-1.9.25) linux/386
1 回答

牛魔王的故事
TA貢獻1830條經驗 獲得超3個贊
深入研究測試標志,我找到了答案。我需要 memprofilerate=1 和 alloc_space
$ goapp test ./cloudstore -memprofilerate=1 -run=none -bench=. -memprofile=cloud.prof
$ go tool pprof --text --alloc_space cloudstore.test cloud.prof
- 1 回答
- 0 關注
- 162 瀏覽
添加回答
舉報
0/150
提交
取消