Win a copy of The Way of the Web Tester: A Beginner's Guide to Automating Tests this week in the Testing forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Velocity thread safe?

Jayesh A Lalwani
Posts: 2762
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic