亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Golang 分析 appengine 測試

Golang 分析 appengine 測試

Go
冉冉說 2021-11-22 15:41:56
我似乎有與接收大文件并將它們發送到 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


查看完整回答
反對 回復 2021-11-22
  • 1 回答
  • 0 關注
  • 162 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號