sing/common/memory/memory.go
2023-09-20 14:03:09 +08:00

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
}