add singbox core(just started)

This commit is contained in:
Yuzuki616
2023-07-28 09:13:11 +08:00
parent 989a9a1ba0
commit 2812b366b3
28 changed files with 1110 additions and 105 deletions

23
core/sing/debug_linux.go Normal file
View File

@@ -0,0 +1,23 @@
package sing
import (
"runtime"
"syscall"
)
func rusageMaxRSS() float64 {
ru := syscall.Rusage{}
err := syscall.Getrusage(syscall.RUSAGE_SELF, &ru)
if err != nil {
return 0
}
rss := float64(ru.Maxrss)
if runtime.GOOS == "darwin" || runtime.GOOS == "ios" {
rss /= 1 << 20 // ru_maxrss is bytes on darwin
} else {
// ru_maxrss is kilobytes elsewhere (linux, openbsd, etc)
rss /= 1 << 10
}
return rss
}