github.com/inazumav/sing-box@v0.0.0-20230926072359-ab51429a14f1/debug_go118.go (about)

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