mirror of
				https://github.com/mickael-kerjean/filestash.git
				synced 2025-11-04 13:35:46 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			478 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			478 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package common
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"runtime"
 | 
						|
)
 | 
						|
 | 
						|
func PrintMemUsage() {
 | 
						|
	var m runtime.MemStats
 | 
						|
	runtime.ReadMemStats(&m)
 | 
						|
	// For info on each, see: https://golang.org/pkg/runtime/#MemStats
 | 
						|
	fmt.Printf("Alloc = %v MiB", bToMb(m.Alloc))
 | 
						|
	fmt.Printf("\tTotalAlloc = %v MiB", bToMb(m.TotalAlloc))
 | 
						|
	fmt.Printf("\tSys = %v MiB", bToMb(m.Sys))
 | 
						|
	fmt.Printf("\tObjects = %d", m.HeapObjects)
 | 
						|
	fmt.Printf("\tNumGC = %v\n", m.NumGC)
 | 
						|
}
 | 
						|
 | 
						|
func bToMb(b uint64) uint64 {
 | 
						|
	return b / 1024 / 1024
 | 
						|
}
 |