From 1c720873298a56083bb8b56ea6c0ee792f3a190a Mon Sep 17 00:00:00 2001 From: Ian Miao Date: Tue, 24 Mar 2020 16:18:17 +0800 Subject: [PATCH] Fix evictedQueue memory leak --- trace/evictedqueue.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/trace/evictedqueue.go b/trace/evictedqueue.go index ffc264f23..a1a2d4f06 100644 --- a/trace/evictedqueue.go +++ b/trace/evictedqueue.go @@ -31,7 +31,9 @@ func newEvictedQueue(capacity int) *evictedQueue { func (eq *evictedQueue) add(value interface{}) { if len(eq.queue) == eq.capacity { - eq.queue = eq.queue[1:] + newQueue := make([]interface{}, eq.capacity-1, eq.capacity) + copy(newQueue, eq.queue[1:]) + eq.queue = newQueue eq.droppedCount++ } eq.queue = append(eq.queue, value)