You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
471 B
28 lines
471 B
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()
|
|
return mem
|
|
}
|