github.com/sagernet/sing@v0.4.0-beta.19.0.20240518125136-f67a0988a636/common/memory/memory.go (about) 1 package memory 2 3 import "runtime" 4 5 func Total() uint64 { 6 if nativeAvailable { 7 return usageNative() 8 } 9 return Inuse() 10 } 11 12 func Inuse() uint64 { 13 var memStats runtime.MemStats 14 runtime.ReadMemStats(&memStats) 15 return memStats.StackInuse + memStats.HeapInuse + memStats.HeapIdle - memStats.HeapReleased 16 }