Standard library / runtime/debug
debug.ReadGCStats()
Fills collection statistics, optionally including pause quantiles. The pause history length can vary. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func ReadGCStats(stats *GCStats)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| stats | *GCStats | Non-nil destination; preallocate PauseQuantiles to request quantiles. |
Working Example
Example Snippetgo
package main
import ( "fmt" "runtime" "runtime/debug" "time")
func main() { runtime.GC() var s debug.GCStats s.PauseQuantiles = make([]time.Duration, 5) debug.ReadGCStats(&s) fmt.Println(s.NumGC > 0 && len(s.PauseQuantiles) == 5)}