Skip to content

Commit

Permalink
give more memory for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Mar 17, 2024
1 parent 51b796d commit 86ca8eb
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions experimental/libbox/memory.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@ import (
runtimeDebug "runtime/debug"

"github.com/sagernet/sing-box/common/conntrack"
C "github.com/sagernet/sing-box/constant"
)

func SetMemoryLimit(enabled bool) {
const memoryLimit = 45 * 1024 * 1024
const memoryLimitGo = memoryLimit / 1.5
var memoryLimit uint64 = 45 * 1024 * 1024
if !C.IsIos {
memoryLimit = 1024 * 1024 * 1024
}
var memoryLimitGo = memoryLimit * 2 / 3
if enabled {
runtimeDebug.SetGCPercent(10)
runtimeDebug.SetMemoryLimit(memoryLimitGo)
runtimeDebug.SetMemoryLimit(int64(memoryLimitGo))
conntrack.KillerEnabled = true
conntrack.MemoryLimit = memoryLimit
} else {
Expand Down

0 comments on commit 86ca8eb

Please sign in to comment.