out.scalar = in.sysStats.heapGoal
},
},
+ "/gc/heap/live:bytes": {
+ deps: makeStatDepSet(heapStatsDep),
+ compute: func(in *statAggregate, out *metricValue) {
+ out.kind = metricKindUint64
+ out.scalar = gcController.heapMarked
+ },
+ },
"/gc/heap/objects:objects": {
deps: makeStatDepSet(heapStatsDep),
compute: func(in *statAggregate, out *metricValue) {
Description: "Heap size target for the end of the GC cycle.",
Kind: KindUint64,
},
+ {
+ Name: "/gc/heap/live:bytes",
+ Description: "Heap memory occupied by live objects that were marked by the previous GC.",
+ Kind: KindUint64,
+ },
{
Name: "/gc/heap/objects:objects",
Description: "Number of objects, live or unswept, occupying heap memory.",
/gc/heap/goal:bytes
Heap size target for the end of the GC cycle.
+ /gc/heap/live:bytes
+ Heap memory occupied by live objects that were marked by the
+ previous GC.
+
/gc/heap/objects:objects
Number of objects, live or unswept, occupying heap memory.
}
func TestReadMetrics(t *testing.T) {
+ // Run a GC cycle to get some of the stats to be non-zero.
+ runtime.GC()
+
// Tests whether readMetrics produces values aligning
// with ReadMemStats while the world is stopped.
var mstats runtime.MemStats
mallocs = samples[i].Value.Uint64()
case "/gc/heap/frees:objects":
frees = samples[i].Value.Uint64()
+ case "/gc/heap/live:bytes":
+ if live := samples[i].Value.Uint64(); live > mstats.HeapAlloc {
+ t.Errorf("live bytes: %d > heap alloc: %d", live, mstats.HeapAlloc)
+ } else if live == 0 {
+ // Might happen if we don't call runtime.GC() above.
+ t.Error("live bytes is 0")
+ }
case "/gc/heap/objects:objects":
checkUint64(t, name, samples[i].Value.Uint64(), mstats.HeapObjects)
case "/gc/heap/goal:bytes":