mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-11-26 02:21:28 +00:00
Add ios memory limit
This commit is contained in:
parent
e8802357e1
commit
8151bcfd6b
|
@ -86,10 +86,10 @@ func buildiOS() {
|
||||||
if !debugEnabled {
|
if !debugEnabled {
|
||||||
args = append(
|
args = append(
|
||||||
args, "-trimpath", "-ldflags=-s -w -buildid=",
|
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 {
|
} 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")
|
args = append(args, "./experimental/libbox")
|
||||||
|
@ -102,7 +102,7 @@ func buildiOS() {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
copyPath := filepath.Join("..", "sfi")
|
copyPath := filepath.Join("..", "sing-box-for-ios")
|
||||||
if rw.FileExists(copyPath) {
|
if rw.FileExists(copyPath) {
|
||||||
targetDir := filepath.Join(copyPath, "Libbox.xcframework")
|
targetDir := filepath.Join(copyPath, "Libbox.xcframework")
|
||||||
targetDir, _ = filepath.Abs(targetDir)
|
targetDir, _ = filepath.Abs(targetDir)
|
||||||
|
|
|
@ -20,7 +20,7 @@ func readStatus() StatusMessage {
|
||||||
var memStats runtime.MemStats
|
var memStats runtime.MemStats
|
||||||
runtime.ReadMemStats(&memStats)
|
runtime.ReadMemStats(&memStats)
|
||||||
var message StatusMessage
|
var message StatusMessage
|
||||||
message.Memory = int64(memStats.HeapInuse + memStats.StackInuse + memStats.MSpanInuse)
|
message.Memory = int64(memStats.Sys - memStats.HeapReleased)
|
||||||
message.Goroutines = int32(runtime.NumGoroutine())
|
message.Goroutines = int32(runtime.NumGoroutine())
|
||||||
return message
|
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