[jboss-jira] [JBoss JIRA] (JGRP-2312) LazyThreadFactory can keep threads instances alive for a long period

Dan Berindei (Jira) issues at jboss.org
Mon Nov 5 07:03:00 EST 2018


    [ https://issues.jboss.org/browse/JGRP-2312?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13656501#comment-13656501 ] 

Dan Berindei commented on JGRP-2312:
------------------------------------

[~belaban] I understand that the cluster name and address may not be known during {{TP.init()}}, but couldn't you create the thread pools only after you know the cluster name and address? To me, the lazy renaming just muddies the initialization story, so it's not clear exactly when the cluster name and address are available.

If you really can't create the thread pool after you know both, {{LazyThreadFactory}} could keep the list until {{TP}} finds out the cluster name and address, but stop keeping track of created threads once the cluster name and address are set.

> LazyThreadFactory can keep threads instances alive for a long period
> --------------------------------------------------------------------
>
>                 Key: JGRP-2312
>                 URL: https://issues.jboss.org/browse/JGRP-2312
>             Project: JGroups
>          Issue Type: Bug
>    Affects Versions: 4.0.15
>            Reporter: William Burns
>            Assignee: Bela Ban
>            Priority: Major
>             Fix For: 4.0.16
>
>
> The LazyThreadFactory keeps all Thread objects in a ConcurrentLinkedQueue wrapped by a WeakReference. This means that once a thread terminates, its instance along with all native memory required for it can linger until the GC eventually reclaims it. Normally this is not an issue when the JVM heap is being recycled often, but in cases where you have low heap requirement operations (ie. off heap data container) this can cause these objects to pile up and eventually exhaust native memory.
> This queue is also a very slow JVM heap leak as threads are tossed out, since the WeakReference and Queue Node objects are never reclaimed unless the transport is stopped.
> The best way to fix this would be to plug into when the thread is set to TERMINATED state and to remove these nodes.
> Also a workaround is to increase the core thread count and increase the keepalive timeout so that threads are not destroyed and created nearly as often.



--
This message was sent by Atlassian Jira
(v7.12.1#712002)


More information about the jboss-jira mailing list