move niling of trace buffer to the end

this avoids holding on memory while we are waiting.
This commit is contained in:
vyzo 2019-11-19 00:07:57 +02:00
parent 91527e2d10
commit 24a1181b9a
1 changed files with 5 additions and 5 deletions

View File

@ -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()