My project is to create a webservice which would connect to a XMPP server and serve as a bridge to send messages to XMPP clients (WS calls -> XMPP messages). Recently, I thought about creating a single connection, which would be shared across all requests (-> my previous question).
But, I was told to create something which would be more scalable and to think about connection pooling. I found a very useful piece of code here. But, I am afraid of memory leaks in Tomcat container – I’ve read too much about it;) Here, I’ve got few questions:
- If I specify that library as a resource, it is automatically created during context initialization. What about memory leaks after e.g. server shutdown? They aren’t destroyed automatically, are they? I understand that I should destroy it manually, creating a ContextListener, but what should I call?
-
If I put into resource definition
removeAbandoned="true" removeAbandonedTimeout="60"will it help to destroy zombie connections from the pool? Is it a correct solution or just a sort of recovering after a disaster?
Any help will be much appreciated, thanks a lot!
If you shut down the server, then you’re shutting down the JVM, and resource leaks won’t matter. The only memory leaks you’ve likely read about in relation to Tomcat is the PermGen problem, which plagues webapp development in general. Don’t worry about the connection pool. It’ll take care of itself.