I think you need to define a Context (in Java) which checks that scripts are behaving sensibly:

http://www.mozilla.org/rhino/apidocs/org/mozilla/javascript/ContextFactory.html



Marcello Bastéa-Forte wrote:
you could catch the exception:
try {
  ... execute javascript ...
} catch (OutOfMemoryError ex) {
  ... do what you want to do ...
}

Marcello

On Wed, Feb 4, 2009 at 11:59 AM, Rhino user <anupama.jo...@gmail.com> wrote:

My script looks like this -
var i = "0";

init("A qucik brown fox jumps over the lazy dog A qucik brown fox
jumps over the lazy dog A qucik brown fox jumps over the lazy dog A
qucik brown fox jumps over the lazy dog A qucik brown fox jumps over
the lazy dog A qucik brown fox jumps over the lazy dog A qucik brown
fox jumps over the lazy dog A qucik brown fox jumps over the lazy dog
A qucik brown fox jumps over the lazy dog A qucik brown fox jumps over
the lazy dog A qucik brown fox jumps over the lazy dog A qucik brown
fox jumps over the lazy dog A qucik brown fox jumps over the lazy dog
A qucik brown fox jumps over the lazy dog A qucik brown fox jumps over
the lazy dog A qucik brown fox jumps over the lazy dog A qucik brown
A qucik brown fox jumps over the lazy dog A qucik brown fox jumps over
the lazy dog A qucik brown fox jumps over the lazy dog A qucik brown
fox jumps over the lazy dog A qucik brown fox jumps over the lazy dog
A qucik brown fox jumps over the lazy dog A qucik brown fox jumps over
the lazy dog A qucik brown fox jumps over the lazy dog A qucik brown
fox jumps over the lazy dog A qucik brown fox jumps over the lazy dog
A qucik brown fox jumps over the lazy dog A qucik brown fox jumps over
the lazy dog A qucik brown fox jumps over the lazy dog ");

function init(s)
{
   while(i=="0")
       s+=s;
}

I get
ava.lang.OutOfMemoryError: Java heap space
       at java.lang.String.concat(String.java:1831)
       at org.mozilla.javascript.ScriptRuntime.add(ScriptRuntime.java:2296)
       at org.mozilla.javascript.gen.c3._c1(externalScript:11)
       at org.mozilla.javascript.gen.c3.call(externalScript)

How can I avoid it?
Thanks
-Anupama
_______________________________________________
dev-tech-js-engine-rhino mailing list
dev-tech-js-engine-rhino@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

_______________________________________________
dev-tech-js-engine-rhino mailing list
dev-tech-js-engine-rhino@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino

Reply via email to