From 892de8e7d745df26e1a91e3fc820b6503344dd74 Mon Sep 17 00:00:00 2001 From: William Waites Date: Tue, 20 Jan 2015 13:16:33 +0000 Subject: [PATCH] Set resource limit for ${java_cmd} -version in sbt initialisation Java is a little anti-social and attempts to lazily allocate all of system memory, even for simple operations such as printing out the version. This causes sbt to fail to start in environments where resources are limited (i.e. ulimit(1)). This setup is common on shared infrastructure such as scientific computing clusters where because of the resource limit not being specified sbt cannot be used. The limit is set to 512MB which ought to be ample and is in any case the default from sbtconfig.txt. A better patch would use the limit specified there but it isn't clear that that is worth the effort. --- src/universal/bin/sbt-launch-lib.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index c761397f6..d57f0e951 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -133,7 +133,7 @@ process_args () { process_my_args "${myargs[@]}" } - java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}') + java_version=$("$java_cmd" -Xmx512M -version 2>&1 | awk -F '"' '/version/ {print $2}') vlog "[process_args] java_version = '$java_version'" }