aboutsummaryrefslogtreecommitdiff
path: root/weed/stats/memory.go
blob: ed51d1a6c9dd8c297e58a9afc1024e5d78a869b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package stats

import (
	"runtime"

	"github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
)

func MemStat() *volume_server_pb.MemStatus {
	mem := &volume_server_pb.MemStatus{}
	mem.Goroutines = int32(runtime.NumGoroutine())
	memStat := new(runtime.MemStats)
	runtime.ReadMemStats(memStat)
	mem.Self = memStat.Alloc
	mem.Heap = memStat.HeapAlloc
	mem.Stack = memStat.StackInuse

	fillInMemStatus(mem)
	return mem
}