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

  1. package stats
  2. import (
  3. "runtime"
  4. )
  5. type MemStatus struct {
  6. Goroutines int
  7. All uint64
  8. Used uint64
  9. Free uint64
  10. Self uint64
  11. Heap uint64
  12. Stack uint64
  13. }
  14. func MemStat() MemStatus {
  15. mem := MemStatus{}
  16. mem.Goroutines = runtime.NumGoroutine()
  17. memStat := new(runtime.MemStats)
  18. runtime.ReadMemStats(memStat)
  19. mem.Self = memStat.Alloc
  20. mem.Heap = memStat.HeapAlloc
  21. mem.Stack = memStat.StackInuse
  22. mem.fillInStatus()
  23. return mem
  24. }