diff --git a/cmd/internal/build_libbox/main.go b/cmd/internal/build_libbox/main.go index 194aa916..de53ec8e 100644 --- a/cmd/internal/build_libbox/main.go +++ b/cmd/internal/build_libbox/main.go @@ -86,10 +86,10 @@ func buildiOS() { if !debugEnabled { args = append( args, "-trimpath", "-ldflags=-s -w -buildid=", - "-tags", "with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api", + "-tags", "with_gvisor,with_utls,with_clash_api", ) } else { - args = append(args, "-tags", "with_gvisor,with_quic,with_wireguard,with_utls,with_clash_api,debug") + args = append(args, "-tags", "with_gvisor,with_utls,with_clash_api,debug") } args = append(args, "./experimental/libbox") @@ -102,7 +102,7 @@ func buildiOS() { log.Fatal(err) } - copyPath := filepath.Join("..", "sfi") + copyPath := filepath.Join("..", "sing-box-for-ios") if rw.FileExists(copyPath) { targetDir := filepath.Join(copyPath, "Libbox.xcframework") targetDir, _ = filepath.Abs(targetDir) diff --git a/experimental/libbox/command_status.go b/experimental/libbox/command_status.go index b9d3210f..cef9a4eb 100644 --- a/experimental/libbox/command_status.go +++ b/experimental/libbox/command_status.go @@ -20,7 +20,7 @@ func readStatus() StatusMessage { var memStats runtime.MemStats runtime.ReadMemStats(&memStats) var message StatusMessage - message.Memory = int64(memStats.HeapInuse + memStats.StackInuse + memStats.MSpanInuse) + message.Memory = int64(memStats.Sys - memStats.HeapReleased) message.Goroutines = int32(runtime.NumGoroutine()) return message } diff --git a/experimental/libbox/memory.go b/experimental/libbox/memory.go new file mode 100644 index 00000000..01bf48a9 --- /dev/null +++ b/experimental/libbox/memory.go @@ -0,0 +1,8 @@ +package libbox + +import "runtime/debug" + +func SetMemoryLimit() { + debug.SetGCPercent(10) + debug.SetMemoryLimit(30 * 1024 * 1024) +}