memory.go 419 B

1234567891011121314151617181920
  1. package stats
  2. import (
  3. "runtime"
  4. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  5. )
  6. func MemStat() *volume_server_pb.MemStatus {
  7. mem := &volume_server_pb.MemStatus{}
  8. mem.Goroutines = int32(runtime.NumGoroutine())
  9. memStat := new(runtime.MemStats)
  10. runtime.ReadMemStats(memStat)
  11. mem.Self = memStat.Alloc
  12. mem.Heap = memStat.HeapAlloc
  13. mem.Stack = memStat.StackInuse
  14. fillInMemStatus(mem)
  15. return mem
  16. }