26 程序资源监控
程序资源监控
运行时资源读取
type MemStats struct {
// General statistics. 常规统计信息。
// 已分配但尚未释放的字节。
Alloc uint64
// 累计已分配。
TotalAlloc uint64
// 从操作系统获取的内存总字节数(近似值)。
Sys uint64
// 对象执行的指针查找的次数 。
Lookups uint64
// 分配的堆对象的累积计数。
Mallocs uint64
// 被释放的堆对象的累积计数。
Frees uint64
// Heap memory statistics. 分配堆内存统计。
// 已分配但尚未释放的字节。
HeapAlloc uint64
// 从os为堆申请的内存大小。
HeapSys uint64
// 空闲 spans 字节。
HeapIdle uint64
// spans 使用中的最大值。
HeapInuse uint64
// 操作系统的物理内存大小。
HeapReleased uint64
// 分配的堆对象总数量。
HeapObjects uint64
// Stack memory statistics. 栈内存统计
// stack不是heap的一部分,但runtime可以将heap内存的一部分用于stack,反之亦可。
// 在stack span的字节。
StackInuse uint64
// 从操作系统中获取的stack内存。
StackSys uint64
// Off-heap memory statistics. 堆外内存统计信息
// 分配的mspan结构的字节。
MSpanInuse uint64
// 从操作系统中获取的用于mspan结构的字节。
MSpanSys uint64
// 已分配的mcache结构的字节。
MCacheInuse uint64
// 从操作系统中分配的mcache结构的字节。
MCacheSys uint64
// 分析bucket哈希表中的内存字节。
BuckHashSys uint64
// GC中元数据的字节。
GCSys uint64
// 其它堆外runtime分配的字节。
OtherSys uint64
// Garbage collector statistics. 垃圾回收器统计信息
// 下次GC目标堆的大小。
NextGC uint64
// 上次GC完成的UNIX时间戳。
LastGC uint64
// 从程序开始时累计暂停时长(STW)纳秒。
PauseTotalNs uint64
// 最近一次的STW时间缓存区,最近一次暂停是在 PauseNs[(NumGC+255)%256],通常它是记录最近 N%256 次的GC记录。
PauseNs [256]uint64
// 最近GC暂停的缓冲区,缓冲区的存放方式与PauseNs一样。每个GC有多个暂停,记录最后一次暂停。
PauseEnd [256]uint64
// 完成的GC数量。
NumGC uint32
// 记录应用通过调用 GC 函数强制GC的次数。
NumForcedGC uint32
// 自程序启动后GC使用CPU时间的分值,其值为0-1之间,0表示gc没有消耗当前程序的CPU(不包括写屏障的cpu时间)。
GCCPUFraction float64
// 启用GC值为true,除非使用GOGC=off设置。
EnableGC bool
// DebugGC is currently unused.当前未使用。
DebugGC bool
// 按 per-size class 大小分配统计
BySize [61]struct {
// Size is the maximum byte size of an object in this
Size uint32
// Mallocs is the cumulative count of heap objects
Mallocs uint64
// Frees is the cumulative count of heap objects freed
Frees uint64
}GODEBUG 和 垃圾回收跟踪



开源监控系统介绍
Last updated