Skip to content

Instantly share code, notes, and snippets.

@collinvandyck
Created March 27, 2016 20:12
Show Gist options
  • Select an option

  • Save collinvandyck/a7aa64473a89113798e7 to your computer and use it in GitHub Desktop.

Select an option

Save collinvandyck/a7aa64473a89113798e7 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"runtime"
"time"
)
func main() {
go func() {
for i := 0; i < 100000; i++ {
<-time.After(10 * time.Millisecond)
}
}()
ms := &runtime.MemStats{}
for _ = range time.Tick(time.Second) {
runtime.GC()
runtime.ReadMemStats(ms)
fmt.Printf("%d Alloc - %d Frees - %d HeapObjects - %d HeapReleased - %d HeapInuse\n", ms.Alloc, ms.Frees, ms.HeapObjects, ms.HeapReleased, ms.HeapInuse)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment