Golang runtime.ReadMemStats() function and MemStats type example
package runtime
Golang runtime.ReadMemStats() function and MemStats type usage example.
NOTE : Very useful in cases like where you want to have accurate breakdown of how Go sees the memory. For example, take snapshot of MemStats to build a memory analyzer application.
package main
import (
"fmt"
"runtime"
)
func main() {
s := new(runtime.MemStats)
runtime.ReadMemStats(s)
fmt.Println("Alloc : ", s.Alloc)
fmt.Println("Total Alloc : ", s.TotalAlloc)
fmt.Println("Sys : ", s.Sys)
fmt.Println("Lookups : ", s.Lookups)
}
References :
Advertisement
Something interesting
Tutorials
+8.8k Android Studio : Image button and button example
+6.3k Golang : Selection sort example
+19.2k Golang : Check if directory exist and create if does not exist
+24.6k Golang : How to print rune, unicode, utf-8 and non-ASCII CJK(Chinese/Japanese/Korean) characters?
+12.1k Golang : convert(cast) string to integer value
+17.2k Google Chrome : Your connection to website is encrypted with obsolete cryptography
+8.2k Golang : Routes multiplexer routing example with regular expression control
+13.7k Golang : Activate web camera and broadcast out base64 encoded images
+15.6k Golang : Convert date format and separator yyyy-mm-dd to dd-mm-yyyy
+25.8k Golang : Daemonizing a simple web server process example
+9.1k Golang : Intercept and compare HTTP response code example
+7k Golang : Gargish-English language translator