You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
redcon temporarily buffers all written data in w.b (a []byte, not an actual bytes.Buffer) of the Writer before writing it to the client during a Flush() operation. maxBufferCap is to ensure that if the temporary internal buffer ever grows above 256KiB, memory from this buffer is afterwards released again during a next run of the garbage collector:
// Flush writes all unflushed Write* calls to the underlying writer.func (w*Writer) Flush() error {
ifw.err!=nil {
returnw.err
}
_, w.err=w.w.Write(w.b)
ifcap(w.b) >maxBufferCap||w.err!=nil {
w.b=nil// <- frees memory during the next gc run
} else {
w.b=w.b[:0] // <- just resets the write cursor/length back to 0 without freeing memory
}
returnw.err
}
Thank you so much for your work on this tool.
Could you please add a comment to this line?
redcon/redcon.go
Line 28 in 52d396e
Is it to ensure buffer cap is bounded? Curious to understand if you have seen an issue in production that triggered this change.
Thanks!
The text was updated successfully, but these errors were encountered: