I have written an EJB 3.1 application that is designed to poll a large number of web servers for their availability. Basically, I have wrapped Apache's SimpleHttpConnectionManager within a SLSB and invoke it asynchronously for every server that I wish to poll. (Each poll is potentially slow if the target server is unavailable, of course). This all works, but I have discovered that the number of instances of my SLSB in memory is slowly rising until JBoss crashes with an OutOfMemory exception. After intensive Googling, I have managed to work around the problem by putting the SLSBs inside a StrictMax pool instead of the default ThreadLocal pool. However, after studying the JMX console, I have discovered that my SLSBs are indeed backed by a thread pool, which makes me wonder why I was having trouble with the ThreadLocal pool in the first place?!
I generated a thread dump using jboss.system:type=ServerInfo and identified that my SLSB is using pool-18-thread-??. When the application runs for the first time, this pool contains threads "pool-18-thread-1" up to "pool-18-thread-12". Shortly afterwards, JBoss prunes away two threads to leave me with only 10, but the bean's RemoveCount (as visible from MBean domain jboss.j2ee) stays at zero. As a result, the application creates two more instances of the bean the next time that it polls the servers, and so the cycle repeats until everything falls over.
Can anyone suggest how I might configure JBoss so that I can use the ThreadLocal pool without also leaking beans, please? I thought that the pool of 10 threads might be defined by the Asynchronous Executor configured inside deployers/jboss-ejb3-async-deployer.jar, but raising that limit made no difference. (And anyway, isn't that a hard limit? The limit I'm hitting appears to be soft.)
This application is basically designed to do repeatedly a lot of slow asynchronous work - any general configuration tips for JBoss 6 would also be much appreciated .
Thanks for any assistance,