|
1 2 3 4 5 6 7 |
// For clearer results it's better to call this function after runtime.GC() invocation. // The code was borrowed from 100 go mistakes book. func printAlloc() { var m runtime.MemStats runtime.ReadMemStats(&m) fmt.Printf("%d KB\n", m.Alloc/1024) } |
Code snippet to print out a go app memory status
Helps to trace memory leaks in a Golang application.