diff --git a/pkg/cache/cache.go b/pkg/cache/cache.go index 1f5f075..3b6d938 100644 --- a/pkg/cache/cache.go +++ b/pkg/cache/cache.go @@ -43,6 +43,9 @@ var bufferPool = sync.Pool{ func getBytesBuffer() ([]byte, func()) { responseBytesBuffer := bufferPool.Get().([]byte)[:0] return responseBytesBuffer, func() { + if cap(responseBytesBuffer) > 256*1024 { + return + } bufferPool.Put(responseBytesBuffer[:0]) } } diff --git a/pkg/cachebehavior/cache.go b/pkg/cachebehavior/cache.go index c92d90a..27495f6 100644 --- a/pkg/cachebehavior/cache.go +++ b/pkg/cachebehavior/cache.go @@ -219,6 +219,9 @@ var bufferPool = sync.Pool{ func getBytesBuffer() ([]byte, func()) { responseBytesBuffer := bufferPool.Get().([]byte)[:0] return responseBytesBuffer, func() { + if cap(responseBytesBuffer) > 256*1024 { + return + } bufferPool.Put(responseBytesBuffer[:0]) } } diff --git a/pkg/upstream/upstream.go b/pkg/upstream/upstream.go index ee8b124..01d6d4b 100644 --- a/pkg/upstream/upstream.go +++ b/pkg/upstream/upstream.go @@ -118,6 +118,9 @@ var bufferPool = sync.Pool{ func getBytesBuffer() ([]byte, func()) { responseBytesBuffer := bufferPool.Get().([]byte)[:0] return responseBytesBuffer, func() { + if cap(responseBytesBuffer) > 256*1024 { + return + } bufferPool.Put(responseBytesBuffer[:0]) } }