Environment:
Ubuntu 8.10
$ uname -a
Linux ... 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 GNU/Linux
$ java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)
Usage:
We are executing a Groovy script at regular intervals using the same instance of GroovyScriptEngine. The number of open files (as reported by the 'lsof' command) keeps increasing every time the script is executed until the number of files the user is allowed to have open is exhaused and a FileNotFoundException (Too many open files) is thrown.
The cause seems to be the URLConnections being opened by the updateCacheEntry method of GroovyScriptEngine.
In the following case, the script being executed is 'execute.script' and this script in turn executes 'request.script'.
lsof -p 7394
...
java 7394 kugan.baladevan 121r REG 8,2 3252 928217 /tmp/jar_cache19005.tmp (deleted)
java 7394 kugan.baladevan 122r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 123r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 124r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 125r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 126u REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 127r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 128r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 129r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 130r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 131r REG 8,2 348 5947460 /.../request.script
...
Getting the InputStream of the URLConnection and closing it seems to fix this issue. The attached svn diff shows the changes.
Environment:
Ubuntu 8.10
$ uname -a
Linux ... 2.6.27-11-generic #1 SMP Thu Jan 29 19:24:39 UTC 2009 i686 GNU/Linux
$ java -version
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Server VM (build 11.0-b15, mixed mode)
Usage:
We are executing a Groovy script at regular intervals using the same instance of GroovyScriptEngine. The number of open files (as reported by the 'lsof' command) keeps increasing every time the script is executed until the number of files the user is allowed to have open is exhaused and a FileNotFoundException (Too many open files) is thrown.
The cause seems to be the URLConnections being opened by the updateCacheEntry method of GroovyScriptEngine.
In the following case, the script being executed is 'execute.script' and this script in turn executes 'request.script'.
lsof -p 7394
...
java 7394 kugan.baladevan 121r REG 8,2 3252 928217 /tmp/jar_cache19005.tmp (deleted)
java 7394 kugan.baladevan 122r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 123r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 124r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 125r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 126u REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 127r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 128r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 129r REG 8,2 348 5947460 /.../request.script
java 7394 kugan.baladevan 130r REG 8,2 4234 5947467 /.../execute.script
java 7394 kugan.baladevan 131r REG 8,2 348 5947460 /.../request.script
...
Getting the InputStream of the URLConnection and closing it seems to fix this issue. The attached svn diff shows the changes.