velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jian chen <chenjian1...@gmail.com>
Subject Re: OutOfMemoryException Processing Velocity Template
Date Thu, 05 May 2005 21:11:28 GMT
Hi,

This maybe because you haven't turned on template caching. I had
similar problem before, and even if I only used evaluate(...) method
and load the template using my own java program, it happened when the
for loop is lot of iterations.

The bottom line for my problem is I need to turn on template caching,
so, velocity will not try to cache the objects it parsed during each
time of the iteration.

I did:
ri.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_CACHE, "true");

where ri is a runtime instance. 

Will this fix your issue?

Cheers,

Jian


On 5/5/05, lawrence@marchex.com <lawrence@marchex.com> wrote:
> I am getting an OutOfMemoryException:
> 
> org.apache.velocity.exception.MethodInvocationException: Invocation of method 'get' in
 class org.apache.velocity.tools.struts.TilesTool threw exception class java.lang.OutOfMemoryError
: null
> 
> when I am creating a large velocity file.  The vm file itself is fairly small, but this
piece of velocity is causing the exception:
> 
> #foreach($row in $List)
> <tr>
> <td height="20" class="tbltxt">$!row.item1</td>
> <td class="tbltxt">$!row.item2</td>
> <td class="tbltxt">$!row.item3</td>
> <td class="tbltxt">$!row.item4</td>
> <td class="tbltxt">$!number.format('currency', $!row.item5)</td>
> </tr>
> #end
> 
> List is a list of relatively small objects (5-6 Strings, a couple of BigDecimals), but
the List itself contains approximately 66,000 entries.  Unfortunately, unless I set the tomcat
JVM to use a heap size of at least 256M, this velocity template throws an OutOfMemoryException
when it is being processed.
> 
> Any suggestions?
> 
> Thanks.
> 
> -L
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
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