Skip to content

Commit ea4d1f6

Browse files
committed
Reduce memory used in chat example
1 parent a91eba7 commit ea4d1f6

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

examples/chat/client.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ func serveWs(hub *Hub, w http.ResponseWriter, r *http.Request) {
129129
}
130130
client := &Client{hub: hub, conn: conn, send: make(chan []byte, 256)}
131131
client.hub.register <- client
132+
133+
// Allow collection of memory referenced by the caller by doing all work in
134+
// new goroutines.
132135
go client.writePump()
133-
client.readPump()
136+
go client.readPump()
134137
}

0 commit comments

Comments
 (0)