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

Thread Locals not being freed in thread pool

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.10.1
    • Component/s: Connection Management
    • None
    • Environment:
      Java

      We are seeing thread local data being left on threads in the thread
      pool of our application running in Tomcat 7 causing a memory leak.
      This problem is not unique to us. The JIRA issues below are described
      by your customers experiencing similar problems

      https://jira.mongodb.org/browse/JAVA-596
      https://jira.mongodb.org/browse/JAVA-130
      https://jira.mongodb.org/browse/JAVA-236

      In JAVA-236, the issue is closed but it does not address the issue.
      The patch seems to miss the point: we want to free the TLS, not close
      the connection.

      Here is the patch we have introduced to your 2.9.10 distribution:

      — src/main/com/mongodb/DBTCPConnector.java.orig 2012-12-03
      12:39:49.000000000 -0700
      +++ src/main/com/mongodb/DBTCPConnector.java 2012-12-11
      08:04:11.000000000 -0700
      @@ -608,6 +608,15 @@
      }

      /**
      + * Release thread local storage for invoking thread. This should
      be called for threads
      + * in thread pools implemented as part of a web framework per
      request. It is not required
      + * for the thread invoking close().
      + */
      + public void release()

      { + _myPort.remove(); + }

      +
      + /**

            Assignee:
            Unassigned Unassigned
            Reporter:
            dtaylor@marketlive.com David Taylor
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: