Uploaded image for project: 'JGroups'
  1. JGroups
  2. JGRP-2312

LazyThreadFactory can keep threads instances alive for a long period

    XMLWordPrintable

Details

    • Bug
    • Status: Resolved (View Workflow)
    • Major
    • Resolution: Done
    • 4.0.15
    • 4.0.16, 3.6.17
    • None

    Description

      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.

      Attachments

        Activity

          People

            rhn-engineering-bban Bela Ban
            wburns@redhat.com Will Burns
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: