velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Lappen <g...@lapcominc.com>
Subject Getting OutOfMemoryError with Velocity 1.4
Date Thu, 12 May 2005 17:28:23 GMT
Hello,

I just started using velocity to generate some HTML emails and I am  
having a problem with memory usage.  My main Java class is run by a  
cron job with the parameter -Xmx256m (256 MB max heap size), but it  
still runs out of memory when I merge the same template with  
different data 1000 times or so.  My code to merge basically looks  
like this:

StringWriter writer = new StringWriter();
try {
     Velocity.mergeTemplate(template, context, writer);
} catch (Exception e) {
     LOG.error("Error merging velocity template:", e);
}
writer.flush();
return writer.toString();

This is executed in a loop, so I am using the same template with a  
new VelocityContext each time through the loop.  We never had memory  
problems before, the only thing that changed was how the html was  
generated (i.e. velocity now instead of StringBuffer appends).

Anyone have this problem or know a way to solve the memory leak?

Thanks,

Greg

---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Mime
View raw message