runtime: make MemStats available to leaking collector

This commit is contained in:
Damian Gryski
2022-08-09 14:01:43 -07:00
committed by Ron Evans
parent ee94f92ede
commit b56baa7aad
4 changed files with 45 additions and 24 deletions
+18
View File
@@ -0,0 +1,18 @@
//go:build gc.leaking
// +build gc.leaking
package runtime
// ReadMemStats populates m with memory statistics.
//
// The returned memory statistics are up to date as of the
// call to ReadMemStats. This would not do GC implicitly for you.
func ReadMemStats(m *MemStats) {
m.HeapIdle = 0
m.HeapInuse = uint64(heapptr - heapStart)
m.HeapReleased = 0 // always 0, we don't currently release memory back to the OS.
m.HeapSys = m.HeapInuse + m.HeapIdle
m.GCSys = 0
m.Sys = uint64(heapEnd - heapStart)
}