Created
February 21, 2011 17:50
-
-
Save rogpeppe/837415 to your computer and use it in GitHub Desktop.
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" | |
"runtime" | |
) | |
func main() { | |
mkmap() | |
log.Println("before GC", runtime.MemStats.HeapAlloc) | |
runtime.GC() | |
log.Println("after GC", runtime.MemStats.HeapAlloc) | |
} | |
func mkmap() map[uint64]interface{} { | |
m := make(map[uint64]interface{}) | |
for i := 0; i < 1e6; i++ { | |
m[uint64(i)] = nil | |
} | |
for i := range m { | |
m[i] = nil, false | |
} | |
return m | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment