From 5eb83dfbd349b069dbf1ec0b2cafc160f743e312 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 20 Apr 2020 17:43:50 -0700 Subject: [PATCH] add memory buffer size limit --- weed/util/log_buffer/log_buffer.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/weed/util/log_buffer/log_buffer.go b/weed/util/log_buffer/log_buffer.go index e733ddc75..e447aacb7 100644 --- a/weed/util/log_buffer/log_buffer.go +++ b/weed/util/log_buffer/log_buffer.go @@ -170,14 +170,15 @@ func (m *LogBuffer) ReadFromBuffer(lastReadTime time.Time) (bufferCopy *bytes.Bu for i, buf := range m.prevBuffers.buffers { if buf.startTime.After(lastReadTime) { if i == 0 { - println("return the earliest in memory") + // println("return the earliest in memory", buf.startTime.UnixNano()) return copiedBytes(buf.buf[:buf.size]) } return copiedBytes(buf.buf[:buf.size]) } if !buf.startTime.After(lastReadTime) && buf.stopTime.After(lastReadTime) { pos := buf.locateByTs(lastReadTime) - return copiedBytes(buf.buf[pos:]) + // fmt.Printf("locate buffer[%d] pos %d\n", i, pos) + return copiedBytes(buf.buf[pos:buf.size]) } } return copiedBytes(m.buf[:m.pos])