V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
Morriaty

Go 碰到的内存问题

  •  
  •   Morriaty · Feb 6, 2018 · 2571 views
    This topic created in 3004 days ago, the information mentioned may be changed or developed.

    通过 linux top 查看到程序占用了 1.8G 内存,但使用 go tool pprof 查看到的只有几 M

    go tool  pprof  http://localhost:6060/debug/pprof/heap
    
    (pprof) top
    Showing nodes accounting for 1.78MB, 100% of 1.78MB total
          flat  flat%   sum%        cum   cum%
        1.78MB   100%   100%     1.78MB   100%  github.com/mozillazg/go-pinyin.init /root/local/go/src/github.com/mozillazg/go-pinyin/pinyin_dict.go
             0     0%   100%     1.78MB   100%  _/root/projections/rpc/gox.init <autogenerated>
             0     0%   100%     1.78MB   100%  main.init <autogenerated>
             0     0%   100%     1.78MB   100%  runtime.main /root/go/src/runtime/proc.go
    (pprof)
    
    
    5 replies    2018-02-06 17:25:33 +08:00
    htfy96
        1
    htfy96  
       Feb 6, 2018
    Go 的 virt 占用大是正常的,res 比较接近实际
    Morriaty
        2
    Morriaty  
    OP
       Feb 6, 2018
    @htfy96 就是 res=1.8G
    Morriaty
        3
    Morriaty  
    OP
       Feb 6, 2018
    cloudzhou
        4
    cloudzhou  
       Feb 6, 2018
    问题是什么呢
    Morriaty
        5
    Morriaty  
    OP
       Feb 6, 2018
    @cloudzhou 问题比较具体,不太好说

    如果碰到相似情况,可以参考 google forum 那篇,是具体解释 pprof/heap 里的字段含义

    还有这篇,具体讲 profile 过程
    https://github.com/bradfitz/talk-yapc-asia-2015/blob/master/talk.md
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   966 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 19:39 · PVG 03:39 · LAX 12:39 · JFK 15:39
    ♥ Do have faith in what you're doing.