Skip to content

Commit

Permalink
Bug-fix/fixes memory leaks in priority queue
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilk1701 authored and ReneKroon committed Dec 6, 2021
1 parent 6eff24f commit e2f836b
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions priority_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ func (pq *priorityQueue) Pop() interface{} {
n := len(old)
item := old[n-1]
item.queueIndex = -1
// de-reference the element to be popped for Garbage Collector to de-allocate the memory
old[n-1] = nil
pq.items = old[0 : n-1]
return item
}

0 comments on commit e2f836b

Please sign in to comment.