mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-09 18:43:14 +00:00
Add ios memory limit
This commit is contained in:
parent
e8802357e1
commit
8151bcfd6b
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
8
experimental/libbox/memory.go
Normal file
8
experimental/libbox/memory.go
Normal file
|
@ -0,0 +1,8 @@
|
|||
package libbox
|
||||
|
||||
import "runtime/debug"
|
||||
|
||||
func SetMemoryLimit() {
|
||||
debug.SetGCPercent(10)
|
||||
debug.SetMemoryLimit(30 * 1024 * 1024)
|
||||
}
|
Loading…
Reference in a new issue