V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
Morriaty
V2EX  ›  Go 编程语言

Go 碰到的内存问题

  •  
  •   Morriaty · 2018-02-06 15:04:50 +08:00 · 1973 次点击
    这是一个创建于 2264 天前的主题,其中的信息可能已经有所发展或是发生改变。

    通过 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 条回复    2018-02-06 17:25:33 +08:00
    htfy96
        1
    htfy96  
       2018-02-06 15:16:15 +08:00
    Go 的 virt 占用大是正常的,res 比较接近实际
    Morriaty
        2
    Morriaty  
    OP
       2018-02-06 15:19:43 +08:00
    @htfy96 就是 res=1.8G
    Morriaty
        3
    Morriaty  
    OP
       2018-02-06 16:08:01 +08:00
    cloudzhou
        4
    cloudzhou  
       2018-02-06 16:17:03 +08:00
    问题是什么呢
    Morriaty
        5
    Morriaty  
    OP
       2018-02-06 17:25:33 +08:00
    @cloudzhou 问题比较具体,不太好说

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

    还有这篇,具体讲 profile 过程
    https://github.com/bradfitz/talk-yapc-asia-2015/blob/master/talk.md
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2793 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 11:42 · PVG 19:42 · LAX 04:42 · JFK 07:42
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.