Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.0-beta-6, 1.0-beta-7
-
None
-
Windows XP SP2, Linux 9.0, 1GB Ram, JDK 1.4.2-4 (server or client), Eclipse 3.0.1
Description
We have a server process that routinely evaluates thousands of simple grovvy expressions daily. Our server process consistently needs to be restarted every two days due to an out of memory error.
We've tracked this down to a leak in groovy. (we've proven this by removing groovy from our application and hard coded the expression results)
If you execute the following piece of code, groovy will cause an out-of-memory error. It consumes over 100mb of heap space, just to evaluated 3 + 4 ten thousand times!
Assuming this is correct, I suggest no one uses groovy in production systems until this is resolved. (I'll have a crack at it myself in the next few days)
//--------------------------
import groovy.lang.GroovyShell;
public class Main {
public static void main(String[] args) throws Exception {
GroovyShell groovyShell = new GroovyShell();
for (int i = 1; i < 10000; i++)
{ Object groovyResult = groovyShell.evaluate("return 3 + 4;"); if (i % 100 == 0) System.out.print("."); } }
}