Hello, I posted the following message in Turbine mailing list. Sorry, if it is not relevant. Thanks, Aravinda. -----Original Message----- From: Aravinda Ghosh Addala [mailto:[EMAIL PROTECTED]] Sent: Thursday, August 16, 2001 14:27 To: [EMAIL PROTECTED] Subject: RE: Memory problem using TurbineVelocity.handleRequest Thanks a lot. I tried with caching turned on, but it didn't help. But, when I created context everytime in the loop, there was no memory leak. I tried this 100,000 iterations. I will definitely post it in velocity-dev list. Aravinda. -----Original Message----- From: jmcnally [mailto:jmcnally]On Behalf Of John McNally Sent: Wednesday, August 15, 2001 21:14 To: [EMAIL PROTECTED] Subject: Re: Memory problem using TurbineVelocity.handleRequest Torque was having a memory problem similar to this and it was solved (I thought), but maybe I only fixed the problem enough for an average size schema to pass through. A memory problem was occuring in velocity when passing the same Context to multiple templates (or the same template multiple times.) The problem does not occur if you are caching templates, so make sure you have that turned on. If you are still experiencing the problem you should try restructuring the code, so that you are creating a new Context for each pass through the loop. I think this is a velocity issue, so you might want to let them in on what your findings are. john mcnally Aravinda Ghosh Addala wrote: > > Hi, > > I have bit strange memory problem. I wrote a java application that uses > standalone Turbine to > send emails using qmail. I have chosen turbine standalone to use different > services, importantyly > TurbineVelocity. > > I have to call TurbineVelocity.handleRequest method in a loop to send > several emails using qmail. > > This application seems to have memory problems and ultimately crashing due > to out of memory. > > I tried to find out the memory used (using java.lang.Runtime) and figured > out that if I comment > TurbineVelocity.handleRequest call there was no memory leak at all. I have > to use this call 500,000 times > in a loop. > > I am using TDK 2.1. > > Any suggestions are much appreciated > > Thanks, > Aravinda > > My code looks like this: > > // Turbine > import org.apache.velocity.context.Context; > import org.apache.turbine.util.TurbineConfig; > import org.apache.turbine.services.resources.TurbineResources; > import org.apache.turbine.services.velocity.TurbineVelocity; > import org.apache.turbine.Turbine; > import org.apache.turbine.util.Log; > import org.apache.turbine.util.ServerData; > import org.apache.turbine.util.template.TemplateLink; > import org.apache.turbine.util.db.pool.DBConnection; > import org.apache.turbine.services.db.TurbineDB; > > //My imports here > > /** > * Application to stream emails to customers using qmail-inject > * > * @author Aravinda > * @version 0.1 > */ > public class SendBulkMails > { > > public SendBulkMails() throws Exception > { > //SOME OTHER CODE > > //Initializing turbine > TurbineConfig tc = new TurbineConfig(".", > "conf/TurbineResources.properties"); > Turbine turbine = new Turbine(); > turbine.init(tc); > > } > > public static void main (String args[]) > { > try > { > long before; > long after; > float time; > > // Create a stream to the log file > FileOutputStream fo = new FileOutputStream("logs/timer.log"); > PrintStream ps = new PrintStream(fo); > > // Initliase turbine > > SendBulkMails mail = new SendBulkMails(); > > // Get the context > Context context = TurbineVelocity.getContext(); > > before = System.currentTimeMillis(); > > int i = 0; > > while(i < numberOfUsers) > { > > customer = new Customer(); > //Other objects > > context.put("Customer" , customer); > > //increment mail count > i++; > > ps.println("Used Mem : " + > (java.lang.Runtime.getRuntime().totalMemory() - > java.lang.Runtime.getRuntime().freeMemory())); > > //send template output to System.out > > TurbineVelocity.handleRequest(context, sEmailTemplate, > System.out); > > System.out.print("\n\n"); > > context.remove("Customer"); > > //TurbineVelocity.requestFinished(context); > > customer = null; > //other objects = null; > > } > > after = System.currentTimeMillis(); > > time = (after - before) / 1000f; > > ps.println("-- Sent " + i + " emails in " + time + " seconds! --"); > > // Close the log stream > ps.close(); > fo.close(); > } > catch(Exception e) > { > //Log error and exis > System.exit(1); > > } > } > > } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
