Standard library / runtime/debug

debug.GCStats

Holds GC count, time, pause history and optional quantiles. This snapshot is not a per-request latency measurement. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
type GCStats struct {  LastGC         time.Time  NumGC          int64  PauseTotal     time.Duration  Pause          []time.Duration  PauseEnd       []time.Time  PauseQuantiles []time.Duration}

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime"  "runtime/debug")
func main() { runtime.GC(); var s debug.GCStats; debug.ReadGCStats(&s); fmt.Println(s.NumGC > 0) }
Go Reference