Last active
July 10, 2023 13:29
-
-
Save hongster/b71d393b79cf111392eb to your computer and use it in GitHub Desktop.
Go runtime 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
package main | |
import ( | |
"fmt" | |
"runtime" | |
) | |
func main() { | |
// https://golang.org/pkg/runtime/#MemStats | |
var memStats runtime.MemStats | |
runtime.ReadMemStats(&memStats) | |
fmt.Printf("Memory in use: %d\n", memStats.Alloc) | |
fmt.Printf("Obtained from system: %d\n", memStats.Sys) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment