我有一个Golang程序,它只实现一个简单的业务逻辑:与服务器端程序建立套接字连接,并维护业务心跳。但是,当此连接不传输任务数据时,pprof报告显示HeapAlloc约为14 it,而inuse_space显示它仅为512 it。为何会有这么大的差异?
pprof HeapAlloc:
# runtime.MemStats
# Alloc = 1386704
# TotalAlloc = 49178232
# Sys = 15285372
# Lookups = 0
# Mallocs = 497504
# Frees = 494691
# HeapAlloc = 1386704
# HeapSys = 12124160
# HeapIdle = 9830400
# HeapInuse = 2293760
# HeapReleased = 8552448
# HeapObjects = 2813
# Stack = 458752 / 458752
# MSpan = 25680 / 32768
# MCache = 1736 / 16384
# BuckHashSys = 727065
# GCSys = 1149056
# OtherSys = 777187
# NextGC = 4194304
# LastGC = 1645580268115312488go工具pprof mem.prof:
Type: inuse_space
Time: Feb 23, 2022 at 10:23am (CST)
Entering interactive mode (type "help" for commands, "o" for options)
(pprof) top5
Showing nodes accounting for 513.12kB, 100% of 513.12kB total
flat flat% sum% cum cum%
513.12kB 100% 100% 513.12kB 100% compress/flate.(*huffmanEncoder).generate
0 0% 100% 513.12kB 100% compress/flate.init.0
0 0% 100% 513.12kB 100% runtime.doInit
0 0% 100% 513.12kB 100% runtime.main发布于 2022-02-23 05:36:54
,为什么会有这么大的差异?
这是两个不同的度量标准。有关值的定义,请参见https://pkg.go.dev/runtime。它还解释了如何解释这种差异。
https://stackoverflow.com/questions/71230949
复制相似问题