sing-box/experimental/libbox/memory.go

19 lines
340 B
Go
Raw Normal View History

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