I actually didn't check whether the ThreadLocal::close worked,
although I see no reason why it shouldn't.
I just created a local version of the driver with the ThreadLocal code
stubbed out, since it so happens that my code structure guarantees a
single Mongo object accessible per thread anyway. I'm assuming the
purpose of the non-static thread local code is to allow many
DBTCPConnectors, each of which can serve multiple threads, but for
each (connector,thread) pair, a single TCP connection is used.
This fixes the memory leak.
FWIW I think you should get the fix in for 2.4 if that isn't already
the plan, because a reasonably standard usage can result in a pretty
slow leak, so people are going to deploy without noticing it.
I'd be interested in knowing the JIRA (or what keywords would narrow
down a search for it), so I can track for when I can return to just
using the off-the-shelf JAR.