Hi, Just for information: Eventually I reduced the memory used by velocity mainly by: -rewriting a few macros in java (the ones that were called most often)
-rewriting a few pages, using loops instead of repeatedly calling the macros The consumption of memory went down from 500Mb to 100Mb --- Bruno Carle <[EMAIL PROTECTED]> wrote: > Hi Nathan > Thanks for your reply, I followed your indications. > > Downloaded velocity 1.5, latest version with svn, > and > it is working fine, I now get a much lower memory > usage by specifying the > resource.manager.defaultcache.size property. > > I guess now I just have to play a bit with this > property. I will also try to move some macros into > java as this seems to decrease memory consumption as > well. > > Have a nice day > Bruno > > > > --- Nathan Bubna <[EMAIL PROTECTED]> wrote: > > > On 8/3/06, bruno <[EMAIL PROTECTED]> wrote: > > > Hello, > > > We are using velocity for our web application, > it > > is working pretty fine > > > but now we have a problem because it consumes > too > > much memory. > > > > > > When I run the application with the property > > > webapp.resource.loader.cache=true > > > after running a sample of 20 request of > different > > pages, the memory used > > > is about 300 Mb . (after garbage collector > calls) > > > > > > After running the same sample with > > > webapp.resource.loader.cache=false , > > > the memory consumption is only about 30Mb! > > > > > > We need to use the cache because of speed (the > > pages are processed more > > > than ten times faster!) but on the other hand, > we > > also would like to run > > > several instances of the application on the same > > computer, so the memory > > > usage is now a limitation for us. > > > > > > I tried using the file resouce loader and I get > > the same results. > > > > > > I have the impression that the velocity performs > a > > kind of compilation > > > of the templates, that are then interpreted and > > optionally cached in memory. > > > Is it possible to cache this 'compiled' > templates > > on disk instead of memory? > > > > Actually, the cache is holding on to the AST > > (abstract syntax tree) > > generated by the parsing of the template file. > > These are just java > > objects. Many years ago there was some work done > on > > compiling > > templates, but this was abandoned as it grew > > apparent that the > > benefits of that were not that great compared to > the > > effort of > > developing it. > > > > So, no, i'm not aware of any way to save the > > templates on disk unless > > it is possible to serialize them (i haven't > checked, > > but i'm skeptical > > that it would be). > > > > > We are using jdk1.5.0_07 and velocity 1.4. I get > > the same results on > > > Windows and Linux. > > > > > > Any suggestions? > > > > Perhaps you could play around with the cache > > settings until you find > > something more useful. I don't remember what the > > default cache impl > > is in 1.4, but in 1.5 it is an LRUMap if the > > following property is set > > to a value > 0. This lets you control the number > of > > templates cached: > > > > resource.manager.defaultcache.size= > > > > You could also implement your own ResourceCache > and > > tell the resource > > manager to use that. > > > > > > > Thanks in advance > > > Bruno > > > > > > Here is our velocity.properties: > > > > > > > > > # velocity.properties > > > #-------------------- > > > > > > > > > > > > velocimacro.library = \ > > > WEB-INF/velocimacros/Global.vm,\ > > > WEB-INF/velocimacros/Debug.vm,\ > > > WEB-INF/velocimacros/Menu.vm,\ > > > WEB-INF/velocimacros/Layout.vm,\ > > > WEB-INF/velocimacros/Buttons.vm,\ > > > WEB-INF/velocimacros/Fields.vm,\ > > > WEB-INF/velocimacros/List.vm,\ > > > WEB-INF/velocimacros/CRUD.vm,\ > > > WEB-INF/velocimacros/Filters.vm,\ > > > WEB-INF/velocimacros/Report.vm,\ > > > WEB-INF/velocimacros/Misc.vm,\ > > > WEB-INF/velocimacros/Ams.vm > > > > > > > > > runtime.log.logsystem.class = > > > > > > org.apache.velocity.runtime.log.SimpleLog4JLogSystem > > > runtime.log.logsystem.log4j.category = Velocity > > > > > > > > > > > > # Default name of the loop counter variable > > reference. > > > directive.foreach.counter.name = velocityCount > > > # Default starting value of the loop counter > > variable reference. > > > directive.foreach.counter.initial.value = 0 > > > > > > resource.loader = webapp > > > webapp.resource.loader.class = > > > > > > org.apache.velocity.tools.view.servlet.WebappLoader > > > > > > > > > ## -- PRODUCTION setup > > > > > > ---------------------------------------------------------------------------------- > > > > > > > > > velocimacro.library.autoreload=false > > > webapp.resource.loader.cache=true > > > > > > > > > > > > --------------------------------------------------------------------- > > > 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] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]