How to Tune the Go Garbage Collector with GOGC

Tune Go garbage collection frequency by setting the GOGC environment variable to a percentage target.

Set the GOGC environment variable to a percentage value representing the target heap growth before the next garbage collection cycle.

export GOGC=200

A value of 200 means the garbage collector runs when the heap grows by 200% of the live data size, effectively delaying GC to reduce frequency but increasing memory usage.