Bug 198345 Memory Leak problem in BIRT.
Memory Leak problem is detected in BIRT 2.2, most of which is supposed caused by unreleased rhino script objects. There are two indentified sources of problem at current stage, both of which are located in class birt.core.script.JavascriptEvalUtil 1.The class keeps a static scriptable object "sharedScope". Because it is a static variable it will not be destroyed until the jvm terminate. We should not use this static scriptable object any more, rather, we should ask client of this class to pass in a scope. 2.The class also keeps a static list "cachedCompiledScript". It is for speeding up the script evaluation process. We should keep this cache to per Data Engine rather than JVM-wise.
core/org.eclipse.birt.core/src/org/eclipse/birt/core/script/JavascriptEvalUtil.java
import org.mozilla.javascript.Context;
import org.mozilla.javascript.IdScriptableObject;
import org.mozilla.javascript.ImporterTopLevel;
import org.mozilla.javascript.RhinoException;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.ScriptRuntime;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Undefined;
import org.mozilla.javascript.Wrapper;
/**
 * Utilities to faciliate the evaluation of Javascript expressions. Handles common evaluation
 * tasks like exception handling, data type conversion and script caching
 */
public class JavascriptEvalUtil
{
    
	private static Scriptable sharedScope;
	
	private static Logger logger = Logger.getLogger( JavascriptEvalUtil.class.getName( ) );
	/*
	 * LRU cache for compiled scripts. For performance reasons, scripts are compiled and put 
	 * in a cache. Repeated evaluation of the same script will then used the compiled binary.
	 * 
	 */
	static protected final int SCRIPT_CACHE_SIZE = 200;
	
	static protected Map compiledScriptCache = Collections.synchronizedMap( 
		new LinkedHashMap( SCRIPT_CACHE_SIZE, (float)0.75, true)
		{