PersistentQueue can potentially leak memory
References to elements pop'ed from PersistentQueue are not immediately removed from the queue. This may lead to situations where the queue holds onto many more objects than it currently contains.
This happens because the PersistentQueue is implemented using two PersistentVectors, one for head, and one for tail. Once the head is empty, the tail vector is transformed into ChunkedSeq (by calling seq on it) and put into the head. However, ChunkedSeq always retains the reference to the whole starting vector, even as it is shrinked with next.
Example, with clj-memory-meter:
Perhaps, if this behavior is expected, it can be at least reflected in the docs somewhere? Given that PQ is already hidden and underdocumented.
EDIT: Changed priority to Minor as this is not a classical memory leak (queue will not grow indefinitely, the biggest leak has the size of the longest streak of conj before pop).