Skip to content

Commit

Permalink
Reduce memory used in chat example
Browse files Browse the repository at this point in the history
  • Loading branch information
garyburd committed Jun 20, 2017
1 parent a91eba7 commit ea4d1f6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/chat/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ func serveWs(hub *Hub, w http.ResponseWriter, r *http.Request) {
}
client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)}
client.hub.register <- client

// Allow collection of memory referenced by the caller by doing all work in
// new goroutines.
go client.writePump()
client.readPump()
go client.readPump()
}

0 comments on commit ea4d1f6

Please sign in to comment.