1

I am setting up a jenkins instance on a VServer with 2GB RAM and nothing else running (usage < 200MB) running CentOS 6.7.

When starting a jenkins build on said instance, I always get this error when jenkins runs gradle --debug --stacktrace test:

19:26:50.727 [ERROR] [org.gradle.BuildExceptionReporter] Caused by: java.lang.OutOfMemoryError: unable to create new native thread

As this seems to be the case of not allowing to many threads I raised the ulimit to:

[root@xxx]# runuser -s /bin/bash jenkins -c 'ulimit -u'

16384

I also tried out different jenkins JVM memory allocation flags, giving the instance 200MB or 1GB changed nothing, lowering the stack size to allow space for native threads has not helped either.

When I run the same gradle command as root, gradle hangs with a similar error:

19:29:14.939 [QUIET] [system.out] Error occurred during initialization of VM 19:29:14.940 [QUIET] [system.out] java.lang.OutOfMemoryError: unable to create new native thread 19:29:14.941 [QUIET] [system.out] at java.lang.Thread.start0(Native Method) 19:29:14.941 [QUIET] [system.out] at java.lang.Thread.start(Thread.java:714) 19:29:14.942 [QUIET] [system.out] at java.lang.ref.Reference.<clinit>(Reference.java:187) 

Is there anything else I can try to fix this?

1 Answer 1

1

You'll want to increase the heap size being given to the Gradle JVM itself, this is not inherited from the Jenkins configuration. You can specify this with the GRADLE_OPTS environment variable, either globally in Jenkins via "Manage Jenkins > Configure System > Global Properties > Environment Variables. You would add a GRADLE_OPTS variable with the appropriate settings. You can also do this on the Gradle invocation by prefixing the command with the environment variable, e.g.:

GRADLE_OPTS="-Xmx256m" ./gradlew build 
1
  • Thanks a lot! Using this command gave gradle enough resources when run in root shell, but when called by jenkins, it does not work as expected. But now I have a working part that just needs adjusting, thanks! Commented Oct 19, 2015 at 6:54

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.