Tagged: ConcurrentLinkedQueue

2

Slowdown and memory leak in ConcurrentLinkedQueue

Yesterday, I stumpled upon a rather interesting memory leak in Java’s ConcurrentLinkedQueue, I’d like to share with you. What is this all about The ConcurrentLinkedQueue leaks memory and slows down when removing the last element of a non-empty queue. Reproducing the problem So to reproduce the leak, we must constantly add and try to remove the last item of an initially filled queue. The following code is showing the problem quite well as it prints the duration it takes for every 10.000 iterations of adding and removing an object to the queue. import java.util.concurrent.ConcurrentLinkedQueue; public class TestLeak { public static...