Improve conntrack

This commit is contained in:
世界
2023-09-20 14:12:08 +08:00
parent 85c8f00885
commit 12dd1ac87f
22 changed files with 223 additions and 57 deletions

View File

@@ -4,14 +4,15 @@ import (
"math"
runtimeDebug "runtime/debug"
"github.com/sagernet/sing-box/common/dialer/conntrack"
"github.com/sagernet/sing-box/common/conntrack"
)
func SetMemoryLimit(enabled bool) {
const memoryLimit = 30 * 1024 * 1024
const memoryLimit = 45 * 1024 * 1024
const memoryLimitGo = memoryLimit / 1.5
if enabled {
runtimeDebug.SetGCPercent(10)
runtimeDebug.SetMemoryLimit(memoryLimit)
runtimeDebug.SetMemoryLimit(memoryLimitGo)
conntrack.KillerEnabled = true
conntrack.MemoryLimit = memoryLimit
} else {