mirror of
https://github.com/SagerNet/sing-box.git
synced 2024-12-02 03:16:36 +00:00
26 lines
440 B
Go
26 lines
440 B
Go
|
//go:build debug
|
||
|
|
||
|
package main
|
||
|
|
||
|
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
|
||
|
}
|