package utils

import (
	"log"
	"runtime"

	"github.com/dustin/go-humanize"
)

var lastTotalFreed uint64

func PrintMemStats() {
	var m runtime.MemStats
	runtime.ReadMemStats(&m)
	log.Printf("[Memory] Alloc = %v TotalAlloc=%v Just Freed = %v Sys = %v NumGc=%v",
		humanize.Bytes(m.Alloc),
		humanize.Bytes(m.TotalAlloc),
		humanize.Bytes(((m.TotalAlloc - m.Alloc) - lastTotalFreed)),
		humanize.Bytes(m.Sys), m.NumGC)
	lastTotalFreed = m.TotalAlloc - m.Alloc
}
