mirror of
https://github.com/shtorm-7/sing-box-extended.git
synced 2026-07-26 00:53:04 +03:00
Add NDIS inbound
This commit is contained in:
@@ -7,17 +7,21 @@ import (
|
||||
"github.com/sagernet/sing-box/common/conntrack"
|
||||
)
|
||||
|
||||
var tracker *conntrack.DefaultTracker
|
||||
|
||||
func SetMemoryLimit(enabled bool) {
|
||||
if tracker != nil {
|
||||
tracker.Close()
|
||||
}
|
||||
const memoryLimit = 45 * 1024 * 1024
|
||||
const memoryLimitGo = memoryLimit / 1.5
|
||||
if enabled {
|
||||
runtimeDebug.SetGCPercent(10)
|
||||
runtimeDebug.SetMemoryLimit(memoryLimitGo)
|
||||
conntrack.KillerEnabled = true
|
||||
conntrack.MemoryLimit = memoryLimit
|
||||
tracker = conntrack.NewDefaultTracker(true, memoryLimit)
|
||||
} else {
|
||||
runtimeDebug.SetGCPercent(100)
|
||||
runtimeDebug.SetMemoryLimit(math.MaxInt64)
|
||||
conntrack.KillerEnabled = false
|
||||
tracker = conntrack.NewDefaultTracker(false, 0)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user