Skip to content

Instantly share code, notes, and snippets.

@rogpeppe
Created February 21, 2011 17:53
Show Gist options
  • Save rogpeppe/837419 to your computer and use it in GitHub Desktop.
Save rogpeppe/837419 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"runtime"
)
func main() {
m := mkmap()
for _ = range m {
break
}
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