func (mu *MemoryUpdater) LogJSON() {
	for _, name := range names {
		max := mu.memTracker[name].Max()
		min := mu.memTracker[name].Min()
		avg := uint64(mu.memTracker[name].Avg())
		log.With().Info("json_mem_data",
			log.String(fmt.Sprintf("%v_max", name), fmt.Sprintf("%v", max)),
			log.String(fmt.Sprintf("%v_min", name), fmt.Sprintf("%v", min)),
			log.String(fmt.Sprintf("%v_avg", name), fmt.Sprintf("%v", avg)))
	}
}
LogJSON returns a string description of the current status as JSON.
package monitoring
import (
	"fmt"
	"runtime"
	"github.com/spacemeshos/go-spacemesh/log"
)
const (
	formatStr  = "Name=%20s\t\tMax=%12v\t\tMin=%12v\t\tAvg=%12v\n"
	jsonFormat = "%v:{max:%v, min:%v, avg:%v},"
)
var names = []string{"NumGoroutine", "Alloc", "TotalAlloc", "Sys", "Mallocs", "Frees", "LiveObjects", "PauseTotalNs", "NumGC"}
type formatter func(uint64) string
func bytesToMBFormmater(x uint64) string {
	return fmt.Sprintf("%vMB", x/1024/1024)
}
type MemoryUpdater struct {
	memTracker   map[string]*Tracker
	formatters   map[string]formatter
	recordsCount int
}
func NewMemoryUpdater() *MemoryUpdater {
	mu := new(MemoryUpdater)
	mu.memTracker = make(map[string]*Tracker)
	mu.formatters = make(map[string]formatter)
	for _, name := range names {
		mu.memTracker[name] = NewTracker()
		mu.formatters[name] = nil
	}
	mu.formatters["Alloc"] = bytesToMBFormmater
	mu.formatters["TotalAlloc"] = bytesToMBFormmater
	return mu
}
func (mu *MemoryUpdater) Update() {
	var rtm runtime.MemStats
	runtime.ReadMemStats(&rtm)
	mu.memTracker["NumGoroutine"].Track(uint64(runtime.NumGoroutine()))
	mu.memTracker["Alloc"].Track(rtm.Alloc)
	mu.memTracker["TotalAlloc"].Track(rtm.TotalAlloc)
	mu.memTracker["Sys"].Track(rtm.Sys)
	mu.memTracker["Mallocs"].Track(rtm.Mallocs)
	mu.memTracker["Frees"].Track(rtm.Frees)
	mu.memTracker["LiveObjects"].Track(rtm.Mallocs - rtm.Frees)
	mu.memTracker["PauseTotalNs"].Track(rtm.PauseTotalNs)
	mu.memTracker["NumGC"].Track(uint64(rtm.NumGC))
	mu.recordsCount++
}
func (mu *MemoryUpdater) Status() string {
	s := fmt.Sprintf("Records count=%v\n", mu.recordsCount)
	for _, name := range names {
		max := mu.memTracker[name].Max()
		min := mu.memTracker[name].Min()
		avg := uint64(mu.memTracker[name].Avg())
		format := mu.formatters[name]
		if format == nil {
			s += fmt.Sprintf(formatStr, name, max, min, avg)
		} else {
			s += fmt.Sprintf(formatStr, name, format(max), format(min), format(avg))
		}
	}
	return s
}