JDK-6805775 : LinkedBlockingQueue Nodes should unlink themselves before becoming garbage
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util.concurrent
  • Affected Version: 6u11,6u22,7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,linux,windows_vista
  • CPU: generic,x86
  • Submitted: 2009-02-15
  • Updated: 2012-07-23
  • Resolved: 2010-11-30
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u17-revFixed 7 b70Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Description
LinkedBlockingQueue Nodes should unlink themselves before becoming garbage,
to prevent tenured Nodes from causing full GCs by retaining a reference to
all younger Nodes in the same queue.

For details and in-depth discussion, see:
http://thread.gmane.org/gmane.comp.java.jsr.166-concurrency/5758

Here's the fix, that has been shown to produce factor of 4 improvement in
a synthetic microbenchmark.

--- src/main/java/util/concurrent/LinkedBlockingQueue.java	18 May 2008
23:47:56 -0000	1.49
+++ src/main/java/util/concurrent/LinkedBlockingQueue.java	12 Feb 2009
01:00:43 -0000	1.50
@@ -133,7 +133,9 @@
      * @return the node
      */
     private E extract() {
-        Node<E> first = head.next;
+        Node<E> h = head;
+        Node<E> first = h.next;
+        h.next = null; // help GC
         head = first;
         E x = first.item;
         first.item = null;

Comments
EVALUATION changeset containing this fix: http://hg.openjdk.java.net/jdk7/tl/jdk/rev/49573ab3096a
07-08-2009

SUGGESTED FIX See Martin Buchholz's preliminary webrev at: http://cr.openjdk.java.net/~martin/webrevs/openjdk7/BlockingQueue/
23-07-2009

EVALUATION Martin Buchholz said the following on 07/11/09 11:21: > > The very focused fix of simply unlinking nodes > when they drop off the queue is wrong, > because it violates the "weakly consistent iterator" guarantees.
11-07-2009

EVALUATION The suggested fix was put into Doug Lea's jsr166y repository but has not yet been pushed to OpenJDK. Martin Buchholz reports: "The fix for this is not yet final. The code changes themselves are final, but there's still a bit of test case work to do."
03-07-2009

SUGGESTED FIX See description.
15-02-2009

EVALUATION See description
15-02-2009