Skip to content

Instantly share code, notes, and snippets.

@jimtla
Created August 21, 2014 22:51
Show Gist options
  • Save jimtla/aa79f4eb9db73e8d7ef1 to your computer and use it in GitHub Desktop.
Save jimtla/aa79f4eb9db73e8d7ef1 to your computer and use it in GitHub Desktop.
Test Program for Golang's heap profiler
package main
import (
"log"
"net/http"
_ "net/http/pprof"
)
func wasteMemory() {
s := "ABCDEFGHIJKLMNOPQRSTUVWXYZ00123456789"
m := map[int]string{}
for i := 0; i < 1000000; i++ {
m[i] = s
if i%1000 == 0 {
log.Println(i)
}
}
}
func main() {
wasteMemory()
log.Println(http.ListenAndServe("localhost:6060", nil))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment