Last active
June 7, 2024 06:31
-
-
Save bagasdisini/5147e8a4abf058fda186c8bd8ef1c24b to your computer and use it in GitHub Desktop.
Go - Print Current Memory Usage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func PrintMemUsage() { | |
var m runtime.MemStats | |
runtime.ReadMemStats(&m) | |
fmt.Printf("Alloc = %v MiB", m.Alloc / 1024 / 1024) | |
fmt.Printf("\tTotalAlloc = %v MiB", m.TotalAlloc / 1024 / 1024) | |
fmt.Printf("\tSys = %v MiB", m.Sys / 1024 / 1024) | |
fmt.Printf("\tNumGC = %v\n", m.NumGC) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment