This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
We have a Velocity Helper class that wraps Velocity engine for processing templates. The helper method is basically this
The thing is VelocityEngine is not really a lightweightt object, and I wanted to see if we can avoid creating an engine eveytime. In my thread dumps I see it loading and parsing some resources from classpath. This creates memory issues in JBoss 5.1 because VelocityEngine ends up calling CFS which has memory leaks. That is a whole another issue of course, but frequent creation of VelocityEngine instances excaberates the JBoss memory leaks. We are going to explode our war so we don;t use VFS.
So, I was wondering if I can just have one instance of VelocityEngine? Is it thread safe?