From b2d9364cb541dc14591b49e730b28dee292d0d5c Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Fri, 16 Mar 2018 22:32:03 +0700 Subject: [PATCH] release buffer if payload becomes small --- common/buf/reader.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/buf/reader.go b/common/buf/reader.go index 87f368086..7c9fa8ce8 100644 --- a/common/buf/reader.go +++ b/common/buf/reader.go @@ -47,6 +47,9 @@ func (r *BytesToBufferReader) ReadMultiBuffer() (MultiBuffer, error) { if nBytes == len(r.buffer) && nBytes < xlSize { freeBytes(r.buffer) r.buffer = newBytes(uint32(nBytes) + 1) + } else if nBytes < Size { + freeBytes(r.buffer) + r.buffer = nil } return mb, nil }