diff options
Diffstat (limited to 'weed/stats/memory.go')
| -rw-r--r-- | weed/stats/memory.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/weed/stats/memory.go b/weed/stats/memory.go new file mode 100644 index 000000000..0700d92de --- /dev/null +++ b/weed/stats/memory.go @@ -0,0 +1,28 @@ +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 +} |
