1
0

debug.go 853 B

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