I've been trying to track down a memory leak with our app in TorqueBox. A few HTTP threads seemed to be retaining an entire JRuby runtime by way of org.jruby.ext.openssl.x509store.X509Error$ErrorException. While I'm not entirely certain that's the root cause, when checking out the class I came across a commit message indicating it doesn't play well with multiple runtimes:
I'm filing the issue so as to not lose that data. @bbrowning, have you ever come across this issue?
So as you found, it isn't really a runtime leak, but because it's a static threadlocal containing references to classloader-loaded types (ErrorException objects) it could cause a thread to keep that classloader alive.
In the end it didn't appear there's any reason for these to be ErrorException objects, so I eliminated that class entirely and just made it a Map<Integer, String> for the error messages.
It's now next-to-useless, but I'm not sure what consumers are using this list of messages for.
No reason to keep these in exception objects as far as I can tell.
@nirvdrum I haven't run across this so far in my testing, but perhaps my test apps didn't do anything with SSL and/or X509 to trigger this issue. Good catch and fix though!