Browse - Programming Tips - Go: Disable/trigger garbage collection

Date: 2019sep21
Language: Go
Keywords: golang

Q.  Go: Disable/trigger garbage collection

A.

Disable the garbage collector:
debug.SetGCPercent(-1)
Trigger garbage collection:
runtime.GC()