Subj : Rhino - limitation on the number of scripts per scope? Better way To : netscape.public.mozilla.jseng From : Dr. S.E. Schleutermann Date : Tue Feb 22 2005 01:50 am Is there a limitation on the number of scripts that can be evaluated / compiled in a scope with cx.evaluateString(...)? My Java software implements a knowledge based system with a rule engine. The rules are written by the user. Each rule is represented by a subclass of ScriptableObject (class RuntimeRule). The rule contents (initialization, conditions, IF-TRUE-actions, ELSE-actions, etc) are translated to JavaScript functions. When I translated each such function into its own script and used cx.evaluateString(, fscript, "internalProcessRule" + i, 1, null); then I ran into Out-of-Memory fairly soon. When I profiled the GC, I saw that thousands of classes *.gen had been generated and collected. Then I concatenated all single function scripts into just one script and did cx.evaluateString(..) only once for each rule. This worked much much better! No more Out-of-Memory! Question: (1) is there a limitation on how many scripts can be handled by Rhino? either per scope or over all scopes. (2) is there perhaps a better way to define functions besides using scripts with text function internalProcessCondition_0() { ..... } perhaps there is a more direct way? Thanks for infos, Sylvia .