Files
sing-box-extended-mirror/debug.go
T

35 lines
865 B
Go
Raw Normal View History

2023-03-17 14:51:09 +08:00
package box
import (
"runtime/debug"
"github.com/sagernet/sing-box/option"
2026-02-26 12:54:00 +08:00
E "github.com/sagernet/sing/common/exceptions"
2023-03-17 14:51:09 +08:00
)
2026-02-26 12:54:00 +08:00
func applyDebugOptions(options option.DebugOptions) error {
2023-04-22 15:58:25 +08:00
applyDebugListenOption(options)
2023-03-17 14:51:09 +08:00
if options.GCPercent != nil {
debug.SetGCPercent(*options.GCPercent)
}
if options.MaxStack != nil {
debug.SetMaxStack(*options.MaxStack)
}
if options.MaxThreads != nil {
debug.SetMaxThreads(*options.MaxThreads)
}
if options.PanicOnFault != nil {
debug.SetPanicOnFault(*options.PanicOnFault)
}
if options.TraceBack != "" {
debug.SetTraceback(options.TraceBack)
}
2025-04-28 23:12:39 +08:00
if options.MemoryLimit.Value() != 0 {
debug.SetMemoryLimit(int64(float64(options.MemoryLimit.Value()) / 1.5))
2023-03-17 14:51:09 +08:00
}
if options.OOMKiller != nil {
2026-02-26 12:54:00 +08:00
return E.New("legacy oom_killer in debug options is removed, use oom-killer service instead")
2023-03-17 14:51:09 +08:00
}
2026-02-26 12:54:00 +08:00
return nil
2023-03-17 14:51:09 +08:00
}