Skip to content

Instantly share code, notes, and snippets.

@RolandWarburton
Created January 23, 2024 11:33
Show Gist options
  • Save RolandWarburton/85e4b3ccd464fa21c8419eea69e7b06e to your computer and use it in GitHub Desktop.
Save RolandWarburton/85e4b3ccd464fa21c8419eea69e7b06e to your computer and use it in GitHub Desktop.
// go tool pprof mem_profile.pprof
func dumpMemoryProfile() {
memProfileFile, err := os.Create("mem_profile.pprof")
if err != nil {
log.Fatal("Could not create memory profile file: ", err)
}
defer memProfileFile.Close()
err = pprof.WriteHeapProfile(memProfileFile)
if err != nil {
log.Fatal("Could not write memory profile: ", err)
}
log.Println("Memory profile written to mem_profile.pprof")
}
@RolandWarburton
Copy link
Author

use the top command and web command top get details about memory usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment