Created
August 21, 2014 22:51
-
-
Save jimtla/aa79f4eb9db73e8d7ef1 to your computer and use it in GitHub Desktop.
Test Program for Golang's heap profiler
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 ( | |
"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