Skip to content

Instantly share code, notes, and snippets.

@davecheney
Created April 7, 2011 11:47
Show Gist options
  • Save davecheney/907622 to your computer and use it in GitHub Desktop.
Save davecheney/907622 to your computer and use it in GitHub Desktop.
package main
import (
"runtime"
"fmt"
"time"
"net"
)
func print() {
for {
<-time.After(10e9)
fmt.Println(runtime.MemStats.Alloc, runtime.MemStats.HeapAlloc)
}
}
func main() {
go print()
addr, _ := net.ResolveTCPAddr(":12345")
l, err := net.ListenTCP("tcp", addr)
if err != nil {
panic(err)
}
for {
c, err := l.Accept()
if err != nil {
panic(err)
}
c.Close()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment