SoFunction
Updated on 2025-03-05

Memorandum of Meaning of Go pprof Memory and Case Analysis

// /golang/go/blob/master/src/runtime/#L150

// Total number of bytes applied from OS
// is the sum of the following XxxSys indicators. Contains the sum of the runtime heap, stack, and other internal data structures.
// It is a virtual memory space. Not necessarily all mapped into physical memory.
Sys

// See `Sys`
HeapSys

// The number of bytes of objects that are still in use and objects that are not used that have not been released by GC
// It should be smooth at normal times, and jagged may appear in gc
HeapAlloc

// The number of object bytes in use.
// There is a detail that if a span can contain multiple objects, as long as one object is used, then the entire span is calculated.
// `HeapInuse` - `HeapAlloc` is a memory reserved in GC and can be used quickly.
HeapInuse

// Memory returned to OS. Memory that has not been heaped and applied for again.
HeapReleased

// The number of bytes of the span that is not used.
// This part of the memory can be returned to the OS and also contains `HeapReleased`.
// Can be applied again, even used as stack memory.
// `HeapIdle` - `HeapReleased` is reserved by GC.
HeapIdle

/// ---

// Same as `HeapAlloc`
Alloc

// Accumulated `Alloc`
// Cumulative means that it continues to increase cumulatively after the program starts and will never decline.
TotalAlloc

// No use
Lookups = 0

// Accumulated number of allocated heap objects
Mallocs

// Accumulated number of heap objects released
Frees

// Number of surviving objects. See `HeapAlloc`
// HeapObjects = `Mallocs` - `Frees`
HeapObjects

// ---
// The meaning of Inuse in XxxInuse below is basically the same as the meaning of Sys in XxxSys.
// There is no XxxIdle because it is included in `HeapIdle`

// StackSys is basically equal to StackInuse, plus the system thread-level stack memory
Stack = StackInuse / StackSys

// Memory used for MSpan structure
MSpan = MSpanInuse / MSpanSys

// Memory used for MCache structure
MCache = MCacheInuse / MCacheSys

// The following are the memory statistics of XxxSys used in the underlying internal data structure
BuckHashSys
GCSys
OtherSys

// ---
// Here are the related GC

// The next time the trigger threshold of GC is, when HeapAlloc reaches this value, it will be GC.
NextGC

// The last time GC's unix timestamp
LastGC

// GC's start and end unix timestamp in each cycle
// There may be 0 GCs in a cycle, or multiple GCs. If it is multiple times, only the last one will be recorded.
PauseNs
PauseEnd

// GC times
NumGC

// The number of times the application forces GC
NumForcedGC

// The total CPU resources occupied by GC. Between 0 and 1
GCCPUFraction

// It's not used, just ignore it
DebugGC