Skip to content

Commit e2f836b

Browse files
nikhilk1701ReneKroon
authored andcommitted
Bug-fix/fixes memory leaks in priority queue
1 parent 6eff24f commit e2f836b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

priority_queue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ func (pq *priorityQueue) Pop() interface{} {
7878
n := len(old)
7979
item := old[n-1]
8080
item.queueIndex = -1
81+
// de-reference the element to be popped for Garbage Collector to de-allocate the memory
82+
old[n-1] = nil
8183
pq.items = old[0 : n-1]
8284
return item
8385
}

0 commit comments

Comments
 (0)