seaweedfs/weed/stats/memory.go

29 lines
471 B
Go
Raw Normal View History

2014-03-26 20:22:27 +00:00
package stats
import (
"runtime"
)
type MemStatus struct {
Goroutines int
All uint64
Used uint64
Free uint64
Self uint64
Heap uint64
Stack uint64
}
func MemStat() MemStatus {
mem := MemStatus{}
mem.Goroutines = runtime.NumGoroutine()
memStat := new(runtime.MemStats)
runtime.ReadMemStats(memStat)
mem.Self = memStat.Alloc
mem.Heap = memStat.HeapAlloc
mem.Stack = memStat.StackInuse
mem.fillInStatus()
2014-03-26 20:22:27 +00:00
return mem
}