How could self link help GC?

Damon Hart-Davis dhd at exnet.com
Sun Jun 21 16:18:30 UTC 2020


By avoiding spurious pointers to h.next keeping the ’next’ item alive longer than necessary.

Rgds

Damon

> On 21 Jun 2020, at 12:59, Robert Lu <robberphex at gmail.com> wrote:
> 
> Hi,
> On java.util.concurrent.LinkedBlockingQueue#dequeue https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java#L217 <https://github.com/openjdk/jdk/blob/master/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java#L217> :
> 
> private E dequeue() {
>     // assert takeLock.isHeldByCurrentThread();
>     // assert head.item == null;
>     Node<E> h = head;
>     Node<E> first = h.next;
>     h.next = h; // help GC
>     head = first;
>     E x = first.item;
>     first.item = null;
>     return x;
> }
> 
> Why does h.next = h help GC?
> 
> -- 
> Robert Lu <robberphex at gmail.com <mailto:robberphex at gmail.com>>
> About me: https://www.robberphex.com/about-me <https://www.robberphex.com/about-me>
> 
> _______________________________________________
> hotspot-gc-use mailing list
> hotspot-gc-use at openjdk.java.net
> https://mail.openjdk.java.net/mailman/listinfo/hotspot-gc-use

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/hotspot-gc-use/attachments/20200621/9f825aa3/attachment.htm>


More information about the hotspot-gc-use mailing list