github.com/koko1123/flow-go-1@v0.29.6/utils/debug/runtime.go (about)

     1  package debug
     2  
     3  import (
     4  	"runtime/metrics"
     5  )
     6  
     7  // GetHeapAllocsBytes returns the value of /gc/heap/allocs:bytes.
     8  func GetHeapAllocsBytes() uint64 {
     9  	// https://pkg.go.dev/runtime/metrics#hdr-Supported_metrics
    10  	sample := []metrics.Sample{{Name: "/gc/heap/allocs:bytes"}}
    11  	metrics.Read(sample)
    12  
    13  	if sample[0].Value.Kind() == metrics.KindUint64 {
    14  		return sample[0].Value.Uint64()
    15  	}
    16  	return 0
    17  }