From 24a1181b9a66dc36f3db0deb1ab3b5c6ac82aa96 Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 19 Nov 2019 00:07:57 +0200 Subject: [PATCH] move niling of trace buffer to the end this avoids holding on memory while we are waiting. --- tracer.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tracer.go b/tracer.go index 724fc15..809cbbe 100644 --- a/tracer.go +++ b/tracer.go @@ -187,11 +187,6 @@ func (t *RemoteTracer) doWrite() { for { _, ok := <-t.ch - // nil out the buffer to gc events when swapping buffers - for i := range buf { - buf[i] = nil - } - // wait a bit to accumulate a batch time.Sleep(time.Second) @@ -220,6 +215,11 @@ func (t *RemoteTracer) doWrite() { } end: + // nil out the buffer to gc consumed events + for i := range buf { + buf[i] = nil + } + if !ok { if err != nil { s.Reset()