Skip to content

Commit

Permalink
Merge pull request #366 from pohly/buffer-size-limit
Browse files Browse the repository at this point in the history
buffer: restore dropping of too large buffers
  • Loading branch information
k8s-ci-robot committed Feb 3, 2023
2 parents 1025055 + 2582956 commit af72dbd
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions internal/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ func GetBuffer() *Buffer {

// PutBuffer returns a buffer to the free list.
func PutBuffer(b *Buffer) {
if b.Len() >= 256 {
// Let big buffers die a natural death, without relying on
// sync.Pool behavior. The documentation implies that items may
// get deallocated while stored there ("If the Pool holds the
// only reference when this [= be removed automatically]
// happens, the item might be deallocated."), but
// https://github.com/golang/go/issues/23199 leans more towards
// having such a size limit.
return
}

buffers.Put(b)
}

Expand Down

0 comments on commit af72dbd

Please sign in to comment.