Go 碰到的内存问题

2018-02-06 15:04:50 +08:00
 Morriaty

通过 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)

1984 次点击
所在节点    Go 编程语言
5 条回复
htfy96
2018-02-06 15:16:15 +08:00
Go 的 virt 占用大是正常的,res 比较接近实际
Morriaty
2018-02-06 15:19:43 +08:00
@htfy96 就是 res=1.8G
Morriaty
2018-02-06 16:08:01 +08:00
cloudzhou
2018-02-06 16:17:03 +08:00
问题是什么呢
Morriaty
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

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/428920

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX