Standard library / runtime

runtime.MemStats

Holds allocator and GC statistics, including current heap allocation, cumulative allocation and collection count. Exact values vary. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type MemStats struct {
  Alloc uint64
  TotalAlloc uint64
  Sys uint64
  Lookups uint64
  Mallocs uint64
  Frees uint64
  HeapAlloc uint64
  HeapSys uint64
  HeapIdle uint64
  HeapInuse uint64
  HeapReleased uint64
  HeapObjects uint64
  StackInuse uint64
  StackSys uint64
  MSpanInuse uint64
  MSpanSys uint64
  MCacheInuse uint64
  MCacheSys uint64
  BuckHashSys uint64
  GCSys uint64
  OtherSys uint64
  NextGC uint64
  LastGC uint64
  PauseTotalNs uint64
  PauseNs [256]uint64
  PauseEnd [256]uint64
  NumGC uint32
  NumForcedGC uint32
  GCCPUFraction float64
  EnableGC bool
  DebugGC bool
  BySize [61]struct {    Size uint32
    Mallocs uint64
    Frees uint64  }}

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() { var m runtime.MemStats; runtime.ReadMemStats(&m); fmt.Println(m.Sys > 0) }
Go Reference