return
}
metrics = map[string]metricData{
+ "/gc/heap/objects:objects": {
+ deps: makeStatDepSet(heapStatsDep),
+ compute: func(in *statAggregate, out *metricValue) {
+ out.kind = metricKindUint64
+ out.scalar = in.heapStats.numObjects
+ },
+ },
"/memory/classes/heap/free:bytes": {
deps: makeStatDepSet(heapStatsDep),
compute: func(in *statAggregate, out *metricValue) {
type heapStatsAggregate struct {
heapStatsDelta
+ // Derived from values in heapStatsDelta.
+
// inObjects is the bytes of memory occupied by objects,
- // derived from other values in heapStats.
inObjects uint64
+
+ // numObjects is the number of live objects in the heap.
+ numObjects uint64
}
// compute populates the heapStatsAggregate with values from the runtime.
// Calculate derived stats.
a.inObjects = uint64(a.largeAlloc - a.largeFree)
+ a.numObjects = uint64(a.largeAllocCount - a.largeFreeCount)
for i := range a.smallAllocCount {
- a.inObjects += uint64(a.smallAllocCount[i]-a.smallFreeCount[i]) * uint64(class_to_size[i])
+ n := uint64(a.smallAllocCount[i] - a.smallFreeCount[i])
+ a.inObjects += n * uint64(class_to_size[i])
+ a.numObjects += n
}
}
// The English language descriptions below must be kept in sync with the
// descriptions of each metric in doc.go.
var allDesc = []Description{
+ {
+ Name: "/gc/heap/objects:objects",
+ Description: "Number of objects, live or unswept, occupying heap memory.",
+ Kind: KindUint64,
+ },
{
Name: "/memory/classes/heap/free:bytes",
Description: "Memory that is available for allocation, and may be returned to the underlying system.",
Supported metrics
+ /gc/heap/objects:objects
+ Number of objects, live or unswept, occupying heap memory.
+
/memory/classes/heap/free:bytes
Memory that is available for allocation, and may be returned
to the underlying system.
checkUint64(t, name, samples[i].Value.Uint64(), mstats.BuckHashSys)
case "/memory/classes/total:bytes":
checkUint64(t, name, samples[i].Value.Uint64(), mstats.Sys)
+ case "/gc/heap/objects:objects":
+ checkUint64(t, name, samples[i].Value.Uint64(), mstats.HeapObjects)
}
}
}