Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-1164

ThreadLocal<Random> anonymous subclass prevents classloader from being garbage collected

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.12.4, 3.0.0
    • Affects Version/s: 2.12.0
    • Component/s: Cluster Management
    • None
    • Fully Compatible

      Quoting from Stefan's comment:

      The problem is how BaseCluster.random is initialized to a ThreadLocal subclass instance. That class references the webapp's classloader. The ThreadLocal subclass in turn is referenced by each Thread instance (that's how ThreadLocals are implemented, they have a "helper-Map" in each Thread instance, so the leak is actually not a tiny Random instance but the whole webapp's classloader with a bunch of class definitions and statically referenced parts of the webapp

            Assignee:
            jeff.yemin@mongodb.com Jeffrey Yemin
            Reporter:
            jkemnade Jochen Kemnade
            Votes:
            2 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: