sing-box/experimental/libbox/memory.go

19 lines
340 B
Go
Raw Normal View History

2023-03-15 14:56:06 +08:00
//go:build darwin
2023-03-02 13:13:12 +08:00
package libbox
2023-03-16 10:55:06 +08:00
import (
runtimeDebug "runtime/debug"
"github.com/sagernet/sing-box/common/dialer/conntrack"
)
const memoryLimit = 30 * 1024 * 1024
2023-03-02 13:13:12 +08:00
func SetMemoryLimit() {
2023-03-16 10:55:06 +08:00
runtimeDebug.SetGCPercent(10)
runtimeDebug.SetMemoryLimit(memoryLimit)
conntrack.KillerEnabled = true
conntrack.MemoryLimit = memoryLimit
2023-03-02 13:13:12 +08:00
}