Skip to content

Commit 684bdac

Browse files
committed
Prevent memory leak
* Allow deleted items to be garbage collected.
1 parent e1e3a34 commit 684bdac

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

queue/priority_queue.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func (items *priorityItems) pop() Item {
4949
// Move last leaf to root, and 'pop' the last item.
5050
items.swap(size-1, 0)
5151
item := (*items)[size-1] // Item to return.
52-
*items = (*items)[:size-1]
52+
(*items)[size-1], *items = nil, (*items)[:size-1]
5353

5454
// 'Bubble down' to restore heap property.
5555
index := 0

0 commit comments

Comments
 (0)