debug.go 653 B

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