SetGCPercent
old := debug.SetGCPercent(200) // less frequent GC
debug.SetGCPercent(-1) // disable
runtime/debugGC tuning, memory limits, stack traces, and build info.
old := debug.SetGCPercent(200) // less frequent GC
debug.SetGCPercent(-1) // disable
debug.SetMemoryLimit(1 << 30) // 1 GiB soft limit
debug.FreeOSMemory() // hint to return memory to the OS
defer func() {
if r := recover(); r != nil {
log.Printf("panic: %v\n%s", r, debug.Stack())
}
}()
if info, ok := debug.ReadBuildInfo(); ok {
fmt.Println(info.Main.Path, info.Main.Version)
for _, s := range info.Settings {
fmt.Println(s.Key, s.Value) // vcs.revision, vcs.time, ...
}
}
debug.SetPanicOnFault(true)
debug.SetTraceback("all") // or "system", "crash"