s-ui/core/debug_unix.go
Alireza Ahmadi afe16b4d2d Sing-Box v1.14.0-rc.2: compile-level upgrade
Re-sync core/protocol/* from upstream (they were verbatim copies), re-fork
core/box.go onto the new upstream box.go, and adapt to changed APIs:

- adapter.ConnectionTracker gained RoutedFlow; add no-op impls to both trackers
- log.ObservableFactory gained AttachPlatformWriter; add no-op impl
- box.Context now takes a CertificateProviderRegistry; wire one up with
  the origin_ca provider
- box.go now depends on debug*.go; copy them from upstream
- hysteria inbound moved QUIC option building into quic.go; copy it

Deps: sing v0.9.0-beta.4, sing-quic v0.7.0-beta.4, sing-tun v0.9.0-beta.2.

Runtime behaviour is not yet validated and config migration for options
deprecated in 1.14 is not done, so this is not ready for main.
2026-08-31 14:06:23 +02:00

25 lines
450 B
Go

//go:build linux || darwin
package core
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
}