You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Sylvain Roche <sy...@add-online.fr> on 2007/10/31 16:36:46 UTC

out of memory /heap overflow after many VelocityEngin.init calls

Hi

while unit testing my project, I encountered an out of memory 
problem. More than 100 test methods resulted in an init call on a 
VelocityEngine
After more or less 35 correct executions, all the next tests launch 
an OutOfMemoryError - heap overflow
I googled for it, and it seems to be a know problem.

Actually for me the thing is not to find a way to run my tests. The 
problem is that the application I'm working on is a generic 
application, made to run many clients. I'm using velocity to make 
html mail templates, and each client has to have his own templates, 
which all are in separate directories. That's why I didn't choose the 
singleton Velocity pattern.

So even if the error I deal with right now is about the number of 
tests I'm running, it's nonetheless symptomatic of a limitation I 
will encounter later.

Is there a known good pattern which would meet my constraints ?

One thing I don't understand is why do I have a OutOfMemoryError. 
Each VelocityEngine is created by a test case. Shouldn't they be 
cleanly destroyed at the end of the test case ? And then why would 
that make an overflow if it was correct ?




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


Re: out of memory /heap overflow after many VelocityEngin.init calls

Posted by Malcolm Edgar <ma...@gmail.com>.
I would recommend that you don't use the singleton pattern.  Create a new
VelocityEngine instance for each invokation. For this type of work it is
quite light weight.

regards Malcolm Edgar

On 11/1/07, Sylvain Roche <sy...@add-online.fr> wrote:
>
> Hi
>
> while unit testing my project, I encountered an out of memory
> problem. More than 100 test methods resulted in an init call on a
> VelocityEngine
> After more or less 35 correct executions, all the next tests launch
> an OutOfMemoryError - heap overflow
> I googled for it, and it seems to be a know problem.
>
> Actually for me the thing is not to find a way to run my tests. The
> problem is that the application I'm working on is a generic
> application, made to run many clients. I'm using velocity to make
> html mail templates, and each client has to have his own templates,
> which all are in separate directories. That's why I didn't choose the
> singleton Velocity pattern.
>
> So even if the error I deal with right now is about the number of
> tests I'm running, it's nonetheless symptomatic of a limitation I
> will encounter later.
>
> Is there a known good pattern which would meet my constraints ?
>
> One thing I don't understand is why do I have a OutOfMemoryError.
> Each VelocityEngine is created by a test case. Shouldn't they be
> cleanly destroyed at the end of the test case ? And then why would
> that make an overflow if it was correct ?
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
> For additional commands, e-mail: user-help@velocity.apache.org
>
>