From 5ea5344773de4b0780796b48b54dac08ae21f70c Mon Sep 17 00:00:00 2001 From: Armon Dadgar Date: Fri, 27 Nov 2015 17:24:21 -0800 Subject: [PATCH] nomad: shrink the recv buffer of idle streams --- nomad/pool.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nomad/pool.go b/nomad/pool.go index 22708ab0f..96328a3f0 100644 --- a/nomad/pool.go +++ b/nomad/pool.go @@ -89,6 +89,12 @@ func (c *Conn) returnClient(client *StreamClient) { if c.clients.Len() < c.pool.maxStreams && atomic.LoadInt32(&c.shouldClose) == 0 { c.clients.PushFront(client) didSave = true + + // If this is a Yamux stream, shrink the internal buffers so that + // we can GC the idle memory + if ys, ok := client.stream.(*yamux.Stream); ok { + ys.Shrink() + } } c.clientLock.Unlock() if !didSave {