Standard library / runtime
runtime.GC()
Runs a garbage collection and blocks until it completes. Usually let automatic GC manage collection. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func GC()Working Example
Example Snippetgo
package main
import ( "fmt" "runtime")
func main() { var a, b runtime.MemStats runtime.ReadMemStats(&a) runtime.GC() runtime.ReadMemStats(&b) fmt.Println(b.NumGC > a.NumGC)}