[Golang]如何檢查記憶體流失(1)

來源:互聯網
上載者:User
這是一個建立於 的文章,其中的資訊可能已經有所發展或是發生改變。[root@s3 twitter]# go tool pprof http://localhost:6060/debug/pprof/heap --text
Read http://localhost:6060/debug/pprof/symbol
Fetching /pprof/heap profile from localhost:6060 to
  /tmp/76z7mNTrzO
Wrote profile to /tmp/76z7mNTrzO
Adjusting heap profiles for 1-in-524288 sampling rate
Total: 47.5 MB
    24.5  51.6%  51.6%     24.5  51.6% reflect.unsafe_NewArray
    23.0  48.4% 100.0%     23.0  48.4% database/sql.convertAssign
     0.0   0.0% 100.0%     23.0  48.4% database/sql.(*Rows).Scan
     0.0   0.0% 100.0%     47.5 100.0% github.com/coopernurse/gorp.(*DbMap).Select
     0.0   0.0% 100.0%     47.5 100.0% github.com/coopernurse/gorp.hookedselect
     0.0   0.0% 100.0%     47.5 100.0% github.com/coopernurse/gorp.rawselect
     0.0   0.0% 100.0%     47.5 100.0% main.getTwitterNoParse
     0.0   0.0% 100.0%     27.5  57.9% main.main
     0.0   0.0% 100.0%     47.5 100.0% main.parseHtml
     0.0   0.0% 100.0%     24.5  51.6% reflect.Append
     0.0   0.0% 100.0%     24.5  51.6% reflect.MakeSlice
     0.0   0.0% 100.0%     24.5  51.6% reflect.grow
     0.0   0.0% 100.0%      1.4   2.9% runtime.MProf_Malloc
     0.0   0.0% 100.0%      1.4   2.9% runtime.callers
     0.0   0.0% 100.0%     25.1  52.8% runtime.gosched0

     0.0   0.0% 100.0%     26.8  56.4% runtime.main


[root@s3 twitter]# go tool pprof http://localhost:6060/debug/pprof/heap --text
Read http://localhost:6060/debug/pprof/symbol
Fetching /pprof/heap profile from localhost:6060 to
  /tmp/6rfif3xDyB
Wrote profile to /tmp/6rfif3xDyB
Adjusting heap profiles for 1-in-524288 sampling rate
Total: 57.1 MB
    30.1  52.7%  52.7%     30.1  52.7% reflect.unsafe_NewArray
    27.0  47.3% 100.0%     27.0  47.3% database/sql.convertAssign
     0.0   0.0% 100.0%     27.0  47.3% database/sql.(*Rows).Scan
     0.0   0.0% 100.0%     57.1 100.0% github.com/coopernurse/gorp.(*DbMap).Select
     0.0   0.0% 100.0%     57.1 100.0% github.com/coopernurse/gorp.hookedselect
     0.0   0.0% 100.0%     57.1 100.0% github.com/coopernurse/gorp.rawselect
     0.0   0.0% 100.0%     57.1 100.0% main.getTwitterNoParse
     0.0   0.0% 100.0%     27.5  48.2% main.main
     0.0   0.0% 100.0%     57.1 100.0% main.parseHtml
     0.0   0.0% 100.0%     30.1  52.7% reflect.Append
     0.0   0.0% 100.0%     30.1  52.7% reflect.MakeSlice
     0.0   0.0% 100.0%     30.1  52.7% reflect.grow
     0.0   0.0% 100.0%      1.4   2.5% runtime.MProf_Malloc
     0.0   0.0% 100.0%      1.4   2.5% runtime.callers
     0.0   0.0% 100.0%     25.1  44.0% runtime.gosched0
     0.0   0.0% 100.0%     26.8  46.9% runtime.main


記憶體佔用在增加!

(pprof) top
Total: 94.1 MB
    49.6  52.7%  52.7%     49.6  52.7% reflect.unsafe_NewArray
    44.5  47.3% 100.0%     44.5  47.3% database/sql.convertAssign
     0.0   0.0% 100.0%     44.5  47.3% database/sql.(*Rows).Scan

產生svg,得安裝graphviz , 瀏覽器開啟svg,圖很清楚。

yum install graphviz -y  

著作權聲明:本文為博主原創文章,未經博主允許不得轉載。

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.