Deque uses data::Vector{T} in DequeBlock{T}, but it only empties this vector in rear blocks, never touching this vector in the head block, instead it only invokes reset! on it. But reset! doesn't unset index on data elements that are no longer valid in this head block, causing these objects not to be garbage collected.
I verified this by taking heap snapshot after inserting and dequeuing all elements and running GC.gc(true) - the elements were still in the heap.
Not sure if other data structures have this behaviour, I only checked for Deque (and by proxy Queue)
Deque uses
data::Vector{T}inDequeBlock{T}, but it only empties this vector in rear blocks, never touching this vector in the head block, instead it only invokesreset!on it. Butreset!doesn't unset index on data elements that are no longer valid in this head block, causing these objects not to be garbage collected.I verified this by taking heap snapshot after inserting and dequeuing all elements and running
GC.gc(true)- the elements were still in the heap.Not sure if other data structures have this behaviour, I only checked for Deque (and by proxy Queue)