github.com/sagernet/sing-box@v1.2.7/debug.go (about) 1 //go:build go1.19 2 3 package box 4 5 import ( 6 "runtime/debug" 7 8 "github.com/sagernet/sing-box/common/dialer/conntrack" 9 "github.com/sagernet/sing-box/option" 10 ) 11 12 func applyDebugOptions(options option.DebugOptions) { 13 if options.GCPercent != nil { 14 debug.SetGCPercent(*options.GCPercent) 15 } 16 if options.MaxStack != nil { 17 debug.SetMaxStack(*options.MaxStack) 18 } 19 if options.MaxThreads != nil { 20 debug.SetMaxThreads(*options.MaxThreads) 21 } 22 if options.PanicOnFault != nil { 23 debug.SetPanicOnFault(*options.PanicOnFault) 24 } 25 if options.TraceBack != "" { 26 debug.SetTraceback(options.TraceBack) 27 } 28 if options.MemoryLimit != 0 { 29 debug.SetMemoryLimit(int64(options.MemoryLimit)) 30 conntrack.MemoryLimit = int64(options.MemoryLimit) 31 } 32 if options.OOMKiller != nil { 33 conntrack.KillerEnabled = *options.OOMKiller 34 } 35 }