mirror of
https://github.com/minio/minio.git
synced 2025-02-23 03:22:30 -05:00
Deallocate huge read buffers (#18813)
If a message buffer is excessively huge, release it back so it isn't kept around forever.
This commit is contained in:
parent
8cd967803c
commit
479940b7d0
@ -899,7 +899,6 @@ func (c *Connection) handleMessages(ctx context.Context, conn net.Conn) {
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if int64(cap(dst)) < hdr.Length+1 {
|
||||
dst = make([]byte, 0, hdr.Length+hdr.Length>>3)
|
||||
}
|
||||
@ -914,6 +913,10 @@ func (c *Connection) handleMessages(ctx context.Context, conn net.Conn) {
|
||||
cancel(ErrDisconnected)
|
||||
return
|
||||
}
|
||||
if cap(msg) > readBufferSize*8 {
|
||||
// Don't keep too much memory around.
|
||||
msg = nil
|
||||
}
|
||||
|
||||
var err error
|
||||
msg, err = readDataInto(msg, conn, c.side, ws.OpBinary)
|
||||
|
Loading…
x
Reference in New Issue
Block a user