mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 12:27:37 +03:00
16 lines
304 B
Go
16 lines
304 B
Go
package memory
|
|
|
|
import "runtime"
|
|
|
|
func Total() uint64 {
|
|
if nativeAvailable {
|
|
return usageNative()
|
|
}
|
|
return Inuse()
|
|
}
|
|
|
|
func Inuse() uint64 {
|
|
var memStats runtime.MemStats
|
|
runtime.ReadMemStats(&memStats)
|
|
return memStats.StackInuse + memStats.HeapInuse + memStats.HeapIdle - memStats.HeapReleased
|
|
}
|