Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit ee8a524

Browse files
committed
Add NextGC
next collection will happen when HeapAlloc ≥ NextGC value
1 parent 7c37910 commit ee8a524

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

runtime/doc.go

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
// Mem.NumGC
1313
// Mem.PauseTotalNs
1414
// Mem.LastGC
15+
// Mem.NextGC
1516
// Mem.Alloc
1617
// Mem.HeapObjects
1718
// Goroutines.Num

runtime/memstats.go

+5
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func init() {
1515
metrics.Gauge("Mem.LastGC").SetBatchFunc(key{}, msg.init, msg.lastPause)
1616
metrics.Gauge("Mem.Alloc").SetBatchFunc(key{}, msg.init, msg.alloc)
1717
metrics.Gauge("Mem.HeapObjects").SetBatchFunc(key{}, msg.init, msg.objects)
18+
metrics.Gauge("Mem.NextGC").SetBatchFunc(key{}, msg.init, msg.nextGC)
1819
}
1920

2021
type key struct{} // unexported to prevent collision
@@ -46,3 +47,7 @@ func (msg *memStatGauges) alloc() int64 {
4647
func (msg *memStatGauges) objects() int64 {
4748
return int64(msg.stats.HeapObjects)
4849
}
50+
51+
func (msg *memStatGauges) nextGC() int64 {
52+
return int64(msg.stats.NextGC)
53+
}

runtime/memstats_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ func TestMemStats(t *testing.T) {
1818
"Mem.LastGC",
1919
"Mem.Alloc",
2020
"Mem.HeapObjects",
21+
"Mem.NextGC",
2122
}
2223

2324
for _, name := range expectedCounters {

0 commit comments

Comments
 (0)